While loop failing
Posted: Mon Mar 22, 2010 11:39 pm
I'm sure this is something extremely simple and I'm overlooking an obvious mistake ( like always ) but considering the fact that I can't seem to find it, I decided to ask for your help.
I'm trying to have it grab the last 20 entries from my SQL database, but it's only grabbing the last one... twenty times. Enough with the explanation, here's my code:
Thanks in advance 
Gahhhh. Found the mistake. Sorry to bother you guys.
For any of you that may want to know how it was fixed, all I did was replace
with
and placed $rank++; outside of the if statement.
[/color]
I'm trying to have it grab the last 20 entries from my SQL database, but it's only grabbing the last one... twenty times. Enough with the explanation, here's my code:
Code: Select all
$rank = 0;
$query = mysql_query("SELECT * FROM `sites` ORDER BY `site_id` DESC");
while($row = mysql_fetch_array($query))
{
while($rank < 20)
{
$rank++;
doWork();
}
}
Gahhhh. Found the mistake. Sorry to bother you guys.
For any of you that may want to know how it was fixed, all I did was replace
Code: Select all
while($rank < 20)
{
Code: Select all
if($rank <= 20)
{
[/color]