mozgras Posted August 19, 2011 Share Posted August 19, 2011 Hi, I'm new to the thread and I'm having an issue using a while loop and it seems mysql_fetch_assoc skips every 3 records. $query = "SELECT `id` FROM `ea_contacts` WHERE 1 ORDER BY id"; $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $id = $row['id']; echo "id=".$id.","; } I'm expecting 1,2,3,4... But I'm getting 1,3,6,9.... Any help would be awesome. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/245162-mysql_fetch_assoc-skips-records/ Share on other sites More sharing options...
MasterACE14 Posted August 19, 2011 Share Posted August 19, 2011 why is there a random 'WHERE' clause and '1' in the query? change it to... $query = "SELECT `id` FROM `ea_contacts` ORDER BY id"; Quote Link to comment https://forums.phpfreaks.com/topic/245162-mysql_fetch_assoc-skips-records/#findComment-1259230 Share on other sites More sharing options...
xyph Posted August 19, 2011 Share Posted August 19, 2011 Are you SURE the IDs in your database aren't 1,3,6,9,etc? Have you verified this with PHPMyAdmin or similar? Quote Link to comment https://forums.phpfreaks.com/topic/245162-mysql_fetch_assoc-skips-records/#findComment-1259240 Share on other sites More sharing options...
mozgras Posted August 19, 2011 Author Share Posted August 19, 2011 Yes - with phpMyAdmin. Quote Link to comment https://forums.phpfreaks.com/topic/245162-mysql_fetch_assoc-skips-records/#findComment-1259256 Share on other sites More sharing options...
trq Posted August 19, 2011 Share Posted August 19, 2011 Is that your exact code? There is nothing in that code that could possibly cause the symptoms you describe. Quote Link to comment https://forums.phpfreaks.com/topic/245162-mysql_fetch_assoc-skips-records/#findComment-1259259 Share on other sites More sharing options...
mozgras Posted August 19, 2011 Author Share Posted August 19, 2011 Thanks very much for your reply - I have other things happening in the while loop... I got rid of everything extraneous and it's working now. Quote Link to comment https://forums.phpfreaks.com/topic/245162-mysql_fetch_assoc-skips-records/#findComment-1259266 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.