ChrisMartino Posted July 17, 2010 Share Posted July 17, 2010 Hello there, well basically my dilemma is that I need to make my while loop only list in orders of 10's so for example if I brought the value '500' from the database I want to list it in order of 10's e.g: while($Value = mysql_fetch_array($TheQuery)) { echo("this would be a integer retruned in a 10"); } So basically I want the figure '500' to be divided up and make it list in the while loop in 10's, does anyone have any suggestions on the best way to accomplish this?. Quote Link to comment https://forums.phpfreaks.com/topic/208057-while-loop-returned-by-10-each-time/ Share on other sites More sharing options...
Pikachu2000 Posted July 17, 2010 Share Posted July 17, 2010 Post a brief diagram of what the results should look like when displayed please . . . Quote Link to comment https://forums.phpfreaks.com/topic/208057-while-loop-returned-by-10-each-time/#findComment-1087587 Share on other sites More sharing options...
ChrisMartino Posted July 17, 2010 Author Share Posted July 17, 2010 10 20 30 40 50 60 70 80 90 100 110 120 130 140 150 160 170 180 190 200 210 And so on. All the way up the preset integer so it would continue to list like that up to 500 for this example. Quote Link to comment https://forums.phpfreaks.com/topic/208057-while-loop-returned-by-10-each-time/#findComment-1087589 Share on other sites More sharing options...
ndee Posted July 17, 2010 Share Posted July 17, 2010 I'm pretty sure you can do that with incrementation. For example: $ii = 0; $i = 10; while($i <= 500) { $query = mysql_query("SELECT * FROM table LIMIT $ii, $i;"); while($row = mysql_fetch_array($query)) { // whatever whatever whatever } $ii = $i; $i = $i + 10; } The code probably doesn't work, but you should get what I'm saying. I'm just using my logic here, and it should work. Good luck mate, Andy. Quote Link to comment https://forums.phpfreaks.com/topic/208057-while-loop-returned-by-10-each-time/#findComment-1087595 Share on other sites More sharing options...
Pikachu2000 Posted July 17, 2010 Share Posted July 17, 2010 So that's it? Just the numbers and no data from the query except the integer to count up to? Quote Link to comment https://forums.phpfreaks.com/topic/208057-while-loop-returned-by-10-each-time/#findComment-1087602 Share on other sites More sharing options...
sasa Posted July 18, 2010 Share Posted July 18, 2010 try $i=0; while($Value = mysql_fetch_array($TheQuery)) { echo($i+=10); } Quote Link to comment https://forums.phpfreaks.com/topic/208057-while-loop-returned-by-10-each-time/#findComment-1087664 Share on other sites More sharing options...
ChrisMartino Posted July 18, 2010 Author Share Posted July 18, 2010 Thanks guys, after some massive brainstorming for a few hours I managed to get this working to my requirements, thanks to everybody that helped me with this!: for ($i = 10; $i < $Package['package_max_slots']; $i += 10) { echo $i; } Quote Link to comment https://forums.phpfreaks.com/topic/208057-while-loop-returned-by-10-each-time/#findComment-1087789 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.