If you want to repeatedly loop through a result set in PHP, you can use
mysql_data_seek($result, 0);
to reset the pointer to the first row. See
http://www.php.net/manual/en/function.mysql-data-seek.php
-steve
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" <[EMAIL PROTECTED]>
>To: <[EMAIL PROTECTED]>
>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():
>>
>> <?php
>> while ($row = mysql_fetch_array($result))
>> {
>> if ($row[col] == 1)
>> {
>> print_entry($row);
>> }
>> }
>> ?>
>>
>> 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
>like
>> 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
>> well...
>>
>> Thanks, marco
>> |
>> | Marco Bleeker, Amsterdam
>> | [EMAIL PROTECTED]
>> | 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 |
| [EMAIL PROTECTED] Computer Consultant |
| http://aesric.ucdavis.edu/ http://pgfsun.ucdavis.edu/ |
+----------------------------------- Douglas Adams 1952 - 11 may 2001 ---+
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php