I have used the following code on one of my pages to place the variables in the URL for the next page:

<?php
$db = mysql_connect("HOST","USERNAME","PASSWORD");
mysql_select_db("DBNAME",$db);
$result = mysql_query("SELECT * FROM TABLE_NAME WHERE FIELD_NAME=??",$db);
while ($myrow = mysql_fetch_row($result)) (
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[7], $mysql[8], "<a href=description.php?II=$myrow[8]&PN=$myrow[0]>Description</a>"));
echo "</table>\n";
?>

and the following code is for the second page.

<?php
$db = mysql_connect("HOST","USERNAME","PASSWORD");
mysql_select_db("DBNAME",$db);
$result = mysql_query("SELECT * FROM TABLE_NAME WHERE FIELD_NAME='$II'",$db);
while ($myrow = mysql_fetch_row($result)) 
(
printf("<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>\n",
$myrow[0], $myrow[1], $myrow[2], $myrow[3], $myrow[4], $myrow[5], $myrow[7], $mysql[8]));
echo "</table>\n";
?>

What I would like to do is to be able to use the link from each row in the first page to open the second page and display the record corresponding to the variables. Caould anyone tell me how to do this or give me some hints on how it might be done.

For security reasons, you should use $_GET. $_GET is for URL variables. If it's form data, you'd need to use $_POST, and for Cookies, $_COOKIE. It's so that you know exactly where your variables are coming from.

To make it work in your code, you'll need to use

$result = mysql_query("SELECT * FROM TABLE_NAME WHERE FIELD_NAME='{$_GET['II']}'",$db);

The { } forces PHP to realise that there's a variable in there - you only need to use those for arrays in strings (like above).

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.