Page 1 of 1

for loops and array

Posted: Sat May 31, 2003 6:42 am
by mzfp2
Hi

I want to use a for loop to iterate through the contents of a mysql_reesult array

something like
for x = 10 to 20 d
{
print $mysql_result[x];
}

but i know this wouldnt work! what is the correct way?

Posted: Sat May 31, 2003 7:42 am
by pootergeist
really I think you should be looking toward using mysql to do the limiting itself, then just run a while to output all results within the limits set

$a = mysql_query("SELECT * FROM `table` WHERE secta='blat' LIMIT 10,10");
while($b = mysql_fetch_array($a))
{
// output here eg echo $b['secta'];
}

check LIMIT in the mysql manual - basically

1 figure - LIMIT 12 - means only shown 12 returns
2 figures - LIMIT 12,10 - means shown 10 returns starting from return number 12 - eg 12-21 (something like that anyway)