wouldn't you use the primary key as the unique identifier? <html> <body> <? if(!isset($_GET['id'])) { // show all records // print a clickable list of first and last names
$sql = "select id,firstname,lastname from contacts"; $result = mysql_query($sql); while($myrow = mysql_fetch_array($result)) { echo "<a href=\"{$_SERVER['PHP_SELF']}?id={$myrow['id']}\">"; echo "{$myrow['firstname']} {$myrow['lastname']}</a>"; } } else { // show the details of a specific contact $sql = "select * from contacts where id='{$_GET['id]}' LIMIT 1"; $result = mysql_query($sql); $myrow = mysql_fetch_array($result); echo "{$myrow['firstname']} {$myrow['lastname']}<br />"; echo "{$myrow['phone']}<br />"; echo "{$myrow['fax']}<br />"; echo "{$myrow['email']}<br />"; } ?> </body> </html> the key line here is echo "<a href=\"{$_SERVER['PHP_SELF']}?id={$myrow['id']}\">"; which puts the ID into the URL, and is used to decide if you want to show all records (no ID in URL) or just one (id in the URL). Have fun, Justin on 17/01/03 2:17 PM, Lars Espelid ([EMAIL PROTECTED]) wrote: > Hello, > > I have a table in a MySQL-db. The primary-key-coloumn is a number which is > not sorted. I don't know how many records there are. > > I have a while-loop in a php-page which prints a link for each record. Each > link points to the same page (iow. page reloads). > > When someone click on one of these links I would like to create a unike > session-variable which identifies the links record and set it's value like > 1. The next time someone click on the link, the variable should be set like > 0. > > The meaning is to run another query if a record's variable is set to 1 and > display it. The page will then have functionality like windows explorer (you > can click on a folder and it will then display its contents). > > The problem is how I can make a unike variable for each record and know how > to call it(know it's name). > > Hope someone understands my problem. (difficult to explain) > > Thanks. > > Lars > > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php