dolcezza Posted November 24, 2007 Share Posted November 24, 2007 I can't figure out why my id field isn't showing anything. It is set to auto-increment in the table. Any help would be appreciated!! I'm new at this! $id=$_GET['id']; $query="SELECT * FROM contacts ORDER BY last ASC"; $result=mysql_query($query); // count how many rows are in the table $num=mysql_num_rows($result); mysql_close(); ?> <table border="0" cellspacing="2" cellpadding="2"> <tr> <th>id</th> <th>Name</th> <th>Venue></th> <th>Phone</th> <th>Mobile</th> <th>Fax</th> <th>E-mail</th> <th>Website</th> <th>Address></th> <th>City</th> <th>State</th> <th>Zip</th> <th>Notes</th> </tr> <?php //loop if ($num==0) {echo"The database contains no records";} else { $i=0; while($i<$num){ $id=mysql_result($id,$i,"id"); $first=mysql_result($result,$i,"first"); $last=mysql_result($result,$i,"last"); $venue=mysql_result($result,$i,"venue"); $phone=mysql_result($result,$i,"phone"); $mobile=mysql_result($result,$i,"mobile"); $fax=mysql_result($result,$i,"fax"); $email=mysql_result($result,$i,"email"); $website=mysql_result($result,$i,"website"); $address=mysql_result($result,$i,"address"); $city=mysql_result($result,$i,"city"); $state=mysql_result($result,$i,"state"); $zip=mysql_result($result,$i,"zip"); $notes=mysql_result($result,$i,"notes"); ?> <tr> <td><? echo $id; ?></td> <td><? echo $last.", ".$first; ?></td> <td><? echo $venue; ?></td> <td><? echo $phone; ?></td> <td><? echo $mobile; ?></td> <td><? echo $fax; ?></td> <td><a href="mailto:<? echo $email; ?>">E-mail</a></td> <td><? echo $website; ?></td> <td><? echo $address; ?></td> <td><? echo $city; ?></td> <td><? echo $state; ?></td> <td><? echo $zip; ?></td> <td><? echo $notes; ?></td> <td><a href='delete.php?id=<?=$id;?>'"'>delete</a></td> </tr> Quote Link to comment https://forums.phpfreaks.com/topic/78639-solved-unique-id-field-not-showing-upnewbie/ Share on other sites More sharing options...
PHP_PhREEEk Posted November 24, 2007 Share Posted November 24, 2007 Someone will be along to re-write this for you. In the meantime, here's a hint: do ALL of the PHP/MySQL stuff FIRST, then echo out the HTML. Closing the connection to MySQL (mysql_close) is probably killing your resource ($result), which means your records can't be returned at the bottom of the script. Get the records once you have a resource, and then format your HTML. PhREEEk Quote Link to comment https://forums.phpfreaks.com/topic/78639-solved-unique-id-field-not-showing-upnewbie/#findComment-397923 Share on other sites More sharing options...
rajivgonsalves Posted November 24, 2007 Share Posted November 24, 2007 this $id=mysql_result($id,$i,"id"); should of been $id=mysql_result($result,$i,"id"); your using the wrong variable for the result set Quote Link to comment https://forums.phpfreaks.com/topic/78639-solved-unique-id-field-not-showing-upnewbie/#findComment-397924 Share on other sites More sharing options...
dolcezza Posted November 24, 2007 Author Share Posted November 24, 2007 Thank You so much!!! I guess I'm looking so hard for complicated mistakes, I miss the obvious!!! Quote Link to comment https://forums.phpfreaks.com/topic/78639-solved-unique-id-field-not-showing-upnewbie/#findComment-397926 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.