justlukeyou Posted March 5, 2011 Share Posted March 5, 2011 I have a list which is echo line by line from a database using the ID number as the identifier. However, the echo has now stopped because I have removed 3 lines. Instead of skipping from ID13 to ID17 it stops at ID13 so whatever else goes into the database it will not display it. Can anyone advise why this may have happened? ID 12 ID 13 break break break ID 17 ID 18 ID 19 Link to comment https://forums.phpfreaks.com/topic/229668-break-in-id-numbers-breaks-echo/ Share on other sites More sharing options...
sasa Posted March 5, 2011 Share Posted March 5, 2011 post relevant code Link to comment https://forums.phpfreaks.com/topic/229668-break-in-id-numbers-breaks-echo/#findComment-1183236 Share on other sites More sharing options...
justlukeyou Posted March 5, 2011 Author Share Posted March 5, 2011 This is the code. Could it be the way my database is set up? It seems to run in a different direct: 13 12 17 18 19 Instead of: 12 13 17 18 19 ini_set('display_errors', 1); error_reporting(-1); { $query = "SELECT * FROM homesoeasy LIMIT 0, 5"; } $result = mysql_query($query); while($row = mysql_fetch_assoc($result)) { $notes = $row['notes']; $question = $row['question']; $id = $row['id']; echo " <div class='questionboxquestion'> $question </div> <div class='questionboxnotes'> $notes </br> </div>"; } // close connection mysql_close(); ?> </div> </div> </div> Link to comment https://forums.phpfreaks.com/topic/229668-break-in-id-numbers-breaks-echo/#findComment-1183310 Share on other sites More sharing options...
cunoodle2 Posted March 5, 2011 Share Posted March 5, 2011 Without any form of "ORDER" to your query it will just display whatever. Try this.. $query = "SELECT * FROM homesoeasy ORDER BY `id` ASC LIMIT 0, 5"; Link to comment https://forums.phpfreaks.com/topic/229668-break-in-id-numbers-breaks-echo/#findComment-1183317 Share on other sites More sharing options...
justlukeyou Posted March 5, 2011 Author Share Posted March 5, 2011 Brilliant thanks, I switched it to descending and it works perfectly. Link to comment https://forums.phpfreaks.com/topic/229668-break-in-id-numbers-breaks-echo/#findComment-1183323 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.