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? Quote Link to comment 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. Quote Link to comment 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 Quote Link to comment Share on other sites More sharing options...
Cagecrawler Posted November 27, 2006 Author Share Posted November 27, 2006 Oops... ::)Thanks guys, works fine now. Quote Link to comment 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.