Quote:
Originally Posted by sabret00the
i saw mist ask for this once but couldn't find the thread
anyhoo i have a loop but i want to exit it early as the query it's using is used for a few more things other than this loop.
i.e. table = 20 rows, loop = 4 rows
not sure about the best way to explain it but if someone could tell me how to do this i'd be eternally grateful 
|
It depends what kind of loop you are doing...but in any event you will have to determine some kind of exit condition, where if that condition is true it will exit the loop.
In a while(), for() or foreach() loop you can use break; to break out of it. Pseudo-code:
PHP Code:
$results = $DB_site->query("my query here");
while ($r = $DB_site->fetch_array($results))
{
// do something or another
// then when we get to the exit condition...
if ($r['rowid'] == 4)
{
break;
}
}