dean7 Posted August 14, 2010 Share Posted August 14, 2010 hi all, I have a piece of code which I coded where it selects all there cars out of the database and shows them, well it is meant to: $getall = mysql_query("SELECT car, id FROM garage WHERE owner='$username'"); $gotall = mysql_fetch_object($getall); echo "$gotall->car - $gotall->id<br />"; Its meant to echo out all the cars which the user own, but for some reason its only echoing one car. Can anyone see why its only showing one car with the id not all the cars they own? Thanks. Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 14, 2010 Share Posted August 14, 2010 You have to use a loop.. <?php $getall = mysql_query("SELECT car, id FROM garage WHERE owner='$username'"); while($row = mysql_fetch_array($getall)){ echo $row['car']. " - ". $row['id']; echo "<br />"; } ?> Quote Link to comment Share on other sites More sharing options...
dean7 Posted August 14, 2010 Author Share Posted August 14, 2010 You have to use a loop.. <?php $getall = mysql_query("SELECT car, id FROM garage WHERE owner='$username'"); while($row = mysql_fetch_array($getall)){ echo $row['car']. " - ". $row['id']; echo "<br />"; } ?> Thanks, that worked Quote Link to comment Share on other sites More sharing options...
Skewled Posted August 14, 2010 Share Posted August 14, 2010 Your most welcome. 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.