If you want to repeatedly loop through a result set in PHP, you can use
to reset the pointer to the first row. See
At 9:33 AM +0800 6/4/01, Rolf Hopkins wrote:
>Yep, that's the way you do it. Put it into a 2D array or even better, a
>class. That's if you are familiar with OOP.
>----- Original Message -----
>From: "Marco Bleeker" <botanicus@stripped>
>Sent: Monday, June 04, 2001 6:57
>Subject: PHP and MySQL result set navigation
>> I do something like this, where $result is the result of a mysql_query():
>> while ($row = mysql_fetch_array($result))
>> if ($row[col] == 1)
>> This is to fill one column on screen. Now I would like to do the same for
>> the second column: if ($row[col] == 2). But the $result pointer has moved
>> to the end. How to move it back to the start again? reset() won't work,
>> because it's not an array, just an integer pointing to a MySQL result set.
>> How to move through this result set using PHP? Or should I just run a
>> seperate query for each column with a 'where col =' clause? That looks
>> pretty intensive use of computer resources... I could also turn the result
>> set into a 2D array of rows and work with that. Sounds a bit voluminous as
>> Thanks, marco
>> | Marco Bleeker, Amsterdam
>> | botanicus@stripped
>> | http://www.euronet.nl/users/mbleeker/
>> | Attachments only after prior notice please.
>> | Don't put me on any kind of mailing list.
>> | I am now receiving the Snowhite virus 4x a day
>> | - some of you must be infected, please check !
>> | (No, you did not get it from me, I use Eudora)
>> | __@
>> | _`\<,_
>> |__(*)/ (*)________________Ah, op DIE fiets !
+--- So long, and thanks for all the fish - -----------------------------+
| Steve Edberg University of California, Davis |
| sbedberg@stripped Computer Consultant |
| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |
+----------------------------------- Douglas Adams 1952 - 11 may 2001 ---+