I have a publications database that lists the search results on one page and then I would like the user to be able to click on a specific record that will then take them to a details page for that record.
On the results page I have the follwoing code:
echo "<a href = details.php?ID=$ID>Report Number</a>";
On the details page I have:
@ $db = mysql_pconnect("servername", "username", "password" );
if (!$db)
{
echo "Error: Could not connect to the database. Please try again later.";
exit;
}
mysql_select_db("dbname");
$query = "SELECT * FROM tablename WHERE ID=$ID";
$result=mysql_query($query);
while ($row=mysql_fetch_array($result))
{
$ID=$row['ID'];
$rptid=$row['rptid'];
$title=$row['title'];
echo $ID;
echo $rptid;
echo $title;
}
mysql_close();
I have also tried:
$query="SELECT * FROM tablename WHERE ID=\"$ID\"";
and a couple other derivations.
Whatever I try, I still can't get the details page to display the information. If I replace
$query = "SELECT FROM tablename WHERE ID=$ID";
with
$query = "SELECT FROM tablename WHERE ID=2";
The details page will display the information for the record with the primary key of 2. So my guess is that the details page is not be handed the $ID from the results page.
I am obviously missing something (other than the appropriate amount of brain cells to figure this out). Anybody have any ideas?? Thanks!!