PHP, MYSQL and hyperlinks – linking from one page to another

hyperlinkMySQLPHP

I have 2 php pages. One returning the id of the last 10 records of a MYSQL query and another returning all field values for a specific record. Can anyone help me link the two so that when I click on say row 3 (id = 3) of the table in the first page it takes me to the second page using the id 3 in the MYSQL query utilised by the second page.

i.e. MYSQL table 'members' with 'id', 'firstname', 'surname', 'dob', and 'address'

Page 1 returns last 10 results of 'select id from members' & the id values are hyperlinks
Page 2 returns results of 'select id, firstname, surname, dob, address from members where id = 3 when user selects the id 3 hyperlink on page 1

Just dont know how to pass '3' to page 2 in the 'where' clause?

Best Answer

Create your links as:

echo '<a href="page2.php?ID='.$row['ID'].'">View Details</a>';

Then page2.php would have something like:

$query = "SELECT firstname, surname, dob, address FROM members WHERE ID=".intval($_REQUEST['ID']);