Cagecrawler Posted November 27, 2006 Share Posted November 27, 2006 I have the following code which is used to list all of the stock items in my system. The only problem is that it isn't showing all of the rows found by the MySQL query. I have 4 dummy data items, but only 3 are shown. My code is below:[code]<?php//Connect to DBinclude("connect.php");$sql="SELECT * FROM stock ORDER BY itemname";$query=mysql_query($sql);$row=mysql_fetch_array($query);echo "<center>";echo "<h1>Current Items in Stock</h1>";echo "Return to <a href=\"index.php\">Home</a>";echo "<table border=1>";echo "<tr>";echo "<td>Item Name</td>";echo "<td>Item Type</td>";echo "<td>Quantity</td>";while($row = mysql_fetch_array($query)) { echo "<tr>"; echo "<td>".$row['itemname']."</td>"; echo "<td>".$row['itemtype']."</td>"; echo "<td>".$row['quantity']."</td>"; echo "</tr>";}echo "</table>";echo "</center>";?>[/code]Any ideas why? Link to comment https://forums.phpfreaks.com/topic/28655-missing-rows-when-taking-data-from-database/ Share on other sites More sharing options...
ToonMariner Posted November 27, 2006 Share Posted November 27, 2006 remove teh first $row=mysql_fetch_array($query) OR use mysql_dataseek to get back to the 0th record. Link to comment https://forums.phpfreaks.com/topic/28655-missing-rows-when-taking-data-from-database/#findComment-131122 Share on other sites More sharing options...
craygo Posted November 27, 2006 Share Posted November 27, 2006 you are creating 2 arrays. No need to do it.try this[code]<?php//Connect to DBinclude("connect.php");$sql="SELECT * FROM stock ORDER BY itemname";$query=mysql_query($sql);echo "<center>";echo "<h1>Current Items in Stock</h1>";echo "Return to <a href=\"index.php\">Home</a>";echo "<table border=1>";echo "<tr>";echo "<td>Item Name</td>";echo "<td>Item Type</td>";echo "<td>Quantity</td>";while($row = mysql_fetch_array($query)) { echo "<tr>"; echo "<td>".$row['itemname']."</td>"; echo "<td>".$row['itemtype']."</td>"; echo "<td>".$row['quantity']."</td>"; echo "</tr>";}echo "</table>";echo "</center>";?>[/code]Ray Link to comment https://forums.phpfreaks.com/topic/28655-missing-rows-when-taking-data-from-database/#findComment-131125 Share on other sites More sharing options...
Cagecrawler Posted November 27, 2006 Author Share Posted November 27, 2006 Oops... ::)Thanks guys, works fine now. Link to comment https://forums.phpfreaks.com/topic/28655-missing-rows-when-taking-data-from-database/#findComment-131131 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.