...

View Full Version : WHILE lOOP limit help



Vernk
10-10-2012, 12:09 AM
$cnt=0;
while($something = mysql_fetch_array($query) true && $cnt<100){
//process....
$cnt++;
}

Will this work , or something like this I am trying to achieve

Wuteverx1972
10-10-2012, 12:35 AM
You can set the limit several ways.

One way is by setting a limit on your query:



$query= mysql_query("SELECT * FROM Persons LIMIT 0,100");

while($row = mysql_fetch_array($query))
{
echo $row['FirstName'] . " " . $row['LastName'];
echo "<br />";
}



Another way is using the for method:


for($i = 0; ($condition) && $i < 100; $i++){
//process
}

Your method should work fine as well but haven't tested it.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum