[thelist] PHP - mysql_fetch_array

Peter Duchateau peter at duo.be
Thu Aug 1 05:19:01 CDT 2002


Thanks Ben,

It works great.

Pete

on 01-08-2002 12:14, Ben Phillips at ben at inchima.com wrote:

>> 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