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?
for loops and array
Moderator: General Moderators
-
pootergeist
- Forum Contributor
- Posts: 273
- Joined: Thu Feb 27, 2003 7:22 am
- Location: UK
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)
$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)