I am wanting to create a dynamic hyperlink using all the ID's in my Database Table which when clicked on the link will load a dynamic page with all the details of the selected ID. Wondering if someone could point out the flaw in my script. I am still pretty novice, c&c welcome:
<?PHP
$host="localhost";
$username="user";
$password="pass";
$conn = mysql_connect($host,$username,$password)
or die(mysql_error());
mysql_select_db("test_db", $conn)
or die(mysql_error());
$q = "SELECT id, first_name, last_name FROM names";
$result = mysql_query ($q);
$num_rows = mysql_num_rows ($result);
IF ($num_rows > 0) {
FOR ($j=0; $j > $num_rows; $j++)
{
$id = mysql_query($result, $j, "id");
$firstname = mysql_query($result, $j, "first_name");
$lastname = mysql_query($result, $j, "last_name");
echo "<a href='index.php?id=", $id, "'>", $firstname, "</a>";
} //close FOR loop
} // close for IF loop
?>