[thelist] PHP - mysql_fetch_array
Ben Phillips
ben at inchima.com
Thu Aug 1 05:15:01 CDT 2002
> I want to loop twice over the result of my sql query.
> 1) show all agents for North America
> 2) show all agents for South America
>
> I never get any agents in the second loop ?
when you loop through the array using mysql_fetch_array(), it moves a
pointer in your query result to the next row. when the loop is finished,
you are then trying to loop through again but because the pointer is at
the end of the result set, it is simply returning no rows on the second
loop.
to fix this, you simply need to reset your pointer in between the two
loops. to do this, use mysql_data_seek():
// first loop here
mysql_data_seek($countries, 0);
// second loop here
benji
inchima.com
More information about the thelist
mailing list