do it with your sql statements
$query = "select * from tablename where fieldname = "whatevervalue";
i usually pass id's thru the query string like
<a href="page.php?id=4">click</a>
then your $query would look like
$query = "select * from tablename where idfieldfromdb = " . $_GET['id'] . ";";
and i'm assuming you know the rest, since you got what you have working