chrisuk Posted September 10, 2008 Share Posted September 10, 2008 Me again! Another query this time. I have this code, pretty straight forward: <?php $getusers = "SELECT * from players ORDER BY points DESC "; $sql= mysql_query($getusers) or die(mysql_error()); $row = mysql_fetch_array($sql, MYSQL_ASSOC); extract ($row); //then i use a while loop to make a table: while ( $row = @mysql_fetch_array ( $sql ) ) ?> My issue is, is that it select's all but one of the records. As a workaround I have added a user "blank" and set the values for the fields to 9999, and so far this means that it has not appeared in results and the data that I want has, but I am curious to know why it doesn't select all the records? I'd rather not have to do crude workarounds! Thanks Link to comment https://forums.phpfreaks.com/topic/123574-solved-mysql_fetch_array-query-not-selecting-all-records/ Share on other sites More sharing options...
DamienRoche Posted September 10, 2008 Share Posted September 10, 2008 I had this issue a couple of weeks back. I can't really apply the solution here, but here's a link that helped me: <a href="http://forums.macrumors.com/archive/index.php/t-97209.html">LINK</a> It's because you are doing a query before the while loop. Hope that helps! Link to comment https://forums.phpfreaks.com/topic/123574-solved-mysql_fetch_array-query-not-selecting-all-records/#findComment-638183 Share on other sites More sharing options...
Mchl Posted September 10, 2008 Share Posted September 10, 2008 You're removing first row from the result set before the loop. Link to comment https://forums.phpfreaks.com/topic/123574-solved-mysql_fetch_array-query-not-selecting-all-records/#findComment-638185 Share on other sites More sharing options...
chrisuk Posted September 10, 2008 Author Share Posted September 10, 2008 Thanks for that guys, that sorted it. I got rid of: <?php $row = mysql_fetch_array($sql, MYSQL_ASSOC); extract ($row); ?> and change the while loop: <?php while ($row = mysql_fetch_array($sql,MYSQL_ASSOC)) ?> And that worked immediately. So thanks, and I've learned something! Link to comment https://forums.phpfreaks.com/topic/123574-solved-mysql_fetch_array-query-not-selecting-all-records/#findComment-638209 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.