Forum Moderators: coopster
[sitename...]
How do I make a link in the database display all of the results for that one item? I am not sure what this is even called, that is my biggest problem of not knowing what to look up. Any help would be appreciated, thank you.
You must create a template as your link says detail.php, this page would include all the information you would like to display from your row.
In this page you must have a Select * From table where id = '$id'
It takes the id from the url.
then simply link like so
<a href="detail.php?id='.$row[id].'">'.$row[item_name].'</a>
If you need anything else just ask.
Here is the coding I used for the display.php page. I still have to clean it up to actually match the site, but the basic working functions are here.
[code]
<?php
mysql_connect("localhost","username","password"); //(host, username, password)
mysql_select_db("database") or die("Unable to select database");
$ad = strip_tags($_GET["ad"]);
$query = "SELECT * FROM tablename WHERE ad = '$ad'";
$result = mysql_query($query) or die(mysql_error());
mysql_close();
while ($row = mysql_fetch_array($result)){
$output .= "
<tr>
<td>".$row["ad"]."</td>
<td>".$row["resort_name"]."</td>
<td>".$row["resort_location"]."</td>
<td>".$row["bed"]."</td>
<td>".$row["bath"]."</td>
<td>".$row["sales_price"]."</td>
<td>".$row["week"]."</td>
</tr>
";
}
$output .= "
</table>
</body>
</html>
";
print $output;
?>
[code]
I had found $ad = strip_tags($_GET["ad"]); in a tutorial I was reading and it worked great. In my actual database, I setup my link like this:
"http://www.sitename.com/display.php?Item1">Item1</a>
So when a search is ran on the site, my results.php script uses that link like this:
while ($row= mysql_fetch_array($result)) {
$itemname = $row["ad_number"];
<a href=$itemname
It works like a charm now. I am not the best at explaining things in PHP for I am still very new and use books to do a lot of my coding. I was able to get this to work and if anyone else is having the same problem as me, ask I and will send you the code I used.
example
I found this code on a webmaster scripts site and its not working can somebody make all the alterations needed and and get my site working because I have no idea what php is but I would like to have a site.
they would reply with code and I would say nope dont work, anyone else
lol
I started experimenting with the codes, reading books. Going through tutorials.
Now I am writing a gaming website which I feel will be a huge success.
Thanks for all your help everyone.
p.s. Jatar, you are pretty good at hiding it.