Forum Moderators: coopster

Message Too Old, No Replies

More info link

         

wendystewart80

2:38 pm on Aug 5, 2005 (gmt 0)

10+ Year Member



Hi, am developing a searchable online mysql database which is accessed through php.
I can search the database to produce results.
I want to display short results, then have a 'more info' link which will lead to more detailed info.
I dont know how to use php / mysql to carry the id from the first results page and link it to the details of the second results page.
At the moment I have:
[php]
$result2 = mysql_query("SELECT catdesc, g.catid FROM def_cats AS d, cats AS g
WHERE g.catid = d.catid AND g.id = ".$r["id"]."
ORDER BY catdesc
")
or die ("Error - ".mysql_error()."");

while($r2=mysql_fetch_array($result2))
{ $catdesc=$r2["catdesc"];
echo "<font face=Arial, Helvetica, sans-serif size=2>$catdesc <br>";
}

echo"<td valign=top align=left width=140><font face=Arial, Helvetica, sans-serif size=2><img src='$image' width='100'><br>";
echo "<a href='searchprojMI.php'>More project info</a></td>";
[/php]

This leads to another similar PHP page but it is not linked to the item the more info button relates to.
How do I link them?
Any advice much appreciated.

dreamcatcher

2:56 pm on Aug 5, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hi wendystewart80,

You need to get the info into a query string. Preferably the id of the article.

<a href='searchprojMI.php?id=ID HERE'>More project info</a>

Then on the searchprojMI.php page use $_GET to get the id and query the database.

$id = $_GET['id'];

$query = mysql_query("SELECT * FROM table WHERE id = '$id' LIMIT 1");

etc etc

dc