Jump to content

Question for While


yakk0

Recommended Posts

You are using a while in a for format.

 

<?php
$count = 0;
// removed the $row = mysql cause that would end the loop prematurely
while ($count <= 100) {
    if ($row = mysql_fetch_array($result)) {
            // process here
     }

    $count++;
}
?>

 

That should work for what you want.

 

With a for statement it would look like this:

<?php
for ($count=0; $count<=100; $count++) {
     if ($row = mysql_fetch_array($result)) {
             // processing here
     }
}
?>

Link to comment
https://forums.phpfreaks.com/topic/132332-question-for-while/#findComment-688002
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.