scotch33 Posted December 19, 2006 Share Posted December 19, 2006 I am trying to list the rows from a table in my page using the following code. The odd thing is that in the MYSQL admin there is sets 109 - 126 yet this code only shows sets 110 - 126. There is no other code on the page that limits what is showing. if i delete all entries and start again I am always showing one less in the mage than the admin is showing. any ideas? thanks!John[code]<? echo "<table class='orderresults_table' border='0' cellspacing='0' cellpadding='0'> <tr class='orderresults_heading'> <td class='orderresults_inv'>Inv No</td> <td class='orderresults_name'>Name</td> <td class='orderresults_date'>Date</td> <td class='orderresults_amount'>Amount</td> <td class='orderresults_button'>More...</td> </tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr class='orderresults_entry'>"; echo "<td class='orderresults_inv'>".$row['inv_no']."</td>"; echo "<td class='orderresults_name'>".$row['cust_name']." ".$row['cust_surname']."</td>"; echo "<td class='orderresults_date'>".$row['date']."</td>"; echo "<td class='orderresults_amount'>£".$row['order_total']."</td>"; echo "<td class='orderresults_button'><form id='detail' name='detail' method='post' action='detail.php'> <input name='inv_no' type='hidden' value='".$row['inv_no']."' /> <input name='submit' type='submit' value='details' /> </form></td>"; echo "</tr>"; } echo"</table>" ?>[/code] Link to comment https://forums.phpfreaks.com/topic/31263-issue-showing-list-of-database-entries-one-is-missing/ Share on other sites More sharing options...
Psycho Posted December 19, 2006 Share Posted December 19, 2006 Please show the code from the time you run the query till that code above starts. Link to comment https://forums.phpfreaks.com/topic/31263-issue-showing-list-of-database-entries-one-is-missing/#findComment-144641 Share on other sites More sharing options...
scotch33 Posted December 20, 2006 Author Share Posted December 20, 2006 [code] $result = mysql_query('SELECT * FROM dvd_orders'); if (!$result) { exit('<p>error performing query:'.mysql_error().'</p>'); } $row = mysql_fetch_array($result);<h2>Orders Summary</h2> <? echo "<table class='orderresults_table' border='0' cellspacing='0' cellpadding='0'> <tr class='orderresults_heading'> <td class='orderresults_inv'>Inv No</td> <td class='orderresults_name'>Name</td> <td class='orderresults_date'>Date</td> <td class='orderresults_amount'>Amount</td> <td class='orderresults_button'>More...</td> </tr>"; while ($row = mysql_fetch_array($result)) { echo "<tr class='orderresults_entry'>"; echo "<td class='orderresults_inv'>".$row['inv_no']."</td>"; echo "<td class='orderresults_name'>".$row['cust_name']." ".$row['cust_surname']."</td>"; echo "<td class='orderresults_date'>".$row['date']."</td>"; echo "<td class='orderresults_amount'>£".$row['order_total']."</td>"; echo "<td class='orderresults_button'><form id='detail' name='detail' method='post' action='detail.php'> <input name='inv_no' type='hidden' value='".$row['inv_no']."' /> <input name='submit' type='submit' value='details' /> </form></td>"; echo "</tr>"; } echo"</table>" ?>[/code] Link to comment https://forums.phpfreaks.com/topic/31263-issue-showing-list-of-database-entries-one-is-missing/#findComment-145090 Share on other sites More sharing options...
Psycho Posted December 20, 2006 Share Posted December 20, 2006 OK, there's your problem.Right after your query you have:$row = mysql_fetch_array($result);Which grabs the first record from your result set. But before you ever use that data, you call this:while ($row = mysql_fetch_array($result)) {Which grabs the 2nd record from the result set. Just remove the first one and you should be fine. Link to comment https://forums.phpfreaks.com/topic/31263-issue-showing-list-of-database-entries-one-is-missing/#findComment-145175 Share on other sites More sharing options...
scotch33 Posted December 20, 2006 Author Share Posted December 20, 2006 aha! That makes sense - great thanks! Link to comment https://forums.phpfreaks.com/topic/31263-issue-showing-list-of-database-entries-one-is-missing/#findComment-145360 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.