Jump to content

While loop, returned by 10 each time.


ChrisMartino

Recommended Posts

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?.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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;
}

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.