Reset pointer for mysql_fetch_array($sth)

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
I'm needing to traverse my $sth twice:

list($date_found, $junk) = mysql_fetch_row($sth);

while (list($date, $stuff1, $stuff2) = mysql_fetch_array($sth)) {
  // do stuff

But of course, when I do this then the WHILE loop starts at 1 instead
of 0 because mysql_fetch_row leaves the internal pointer at 1. I tried
reset($sth), but this just gives an error that $sth isn't an array.

Is there a way to reset the internal pointer without running a new



Re: Reset pointer for mysql_fetch_array($sth)

.oO(Jason Carlton)

Quoted text here. Click to load it

There's mysql_data_seek(), but why not simply fetch all the data into an
array first and then loop through it as often as you want? That would be
more reliable and portable.


Site Timeline