gathos Posted September 4, 2008 Share Posted September 4, 2008 ok so when i try to display my database info in a table of 3 columns, it display 1 2 3 5 6 i'm getting it to show the id's of the entries, make debuggin easier. so why does it skip 4? here's my code <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <? mysql_connect("localhost","username","password"); mysql_select_db("database"); // these were changed to protect my username password and database $result=mysql_query("select * from traddb order by id asc"); Echo "<table border='1'>"; while($row=mysql_fetch_assoc($result)){ echo "<tr> <td>"; echo $row['id']; $row=mysql_fetch_assoc($result); echo" </td> <td>"; echo $row['id']; $row=mysql_fetch_assoc($result); echo" </td> <td>"; echo $row['id']; $row=mysql_fetch_assoc($result); echo " </td> </tr>"; } echo "</table>"; ?> </body> </html> so any reason why this might happen? thanks. later days, gathos Link to comment https://forums.phpfreaks.com/topic/122799-solved-displaying-databasae-in-table-some-missing/ Share on other sites More sharing options...
underparnv Posted September 4, 2008 Share Posted September 4, 2008 Try this (note that it is "air code" ) <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>Untitled Document</title> </head> <body> <? mysql_connect("localhost","username","password"); mysql_select_db("database"); // these were changed to protect my username password and database $result=mysql_query("select * from traddb order by id asc"); $count = 1; echo "<table border=\"1\">"; while($row = mysql_fetch_assoc($result)) { if ($count == 1) { echo "<tr>"; } echo "<td>" . $row["id"] . "</td>"; if ($count == 4) { echo "</tr>"; $count = 0; } $count++; } echo "</table>"; ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/122799-solved-displaying-databasae-in-table-some-missing/#findComment-634123 Share on other sites More sharing options...
.josh Posted September 4, 2008 Share Posted September 4, 2008 Perhaps your id column is unique auto-inc and for some reason 4 was deleted? Link to comment https://forums.phpfreaks.com/topic/122799-solved-displaying-databasae-in-table-some-missing/#findComment-634124 Share on other sites More sharing options...
gathos Posted September 5, 2008 Author Share Posted September 5, 2008 thanks underparnv, i was able to fine tune your code to help, i appreciate that. i tell ya, this forum is great. nice people and lots of help. thanks, gathos Link to comment https://forums.phpfreaks.com/topic/122799-solved-displaying-databasae-in-table-some-missing/#findComment-634645 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.