faqts : Computers : Programming : Languages : PHP : Database Backed Sites : MySQL

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

45 of 46 people (98%) answered Yes
Recently 10 of 10 people (100%) answered Yes

Entry

How do I loop twice through a result set from a mysql query? I don't seem to be able to use reset() to reset the pointer to the beginning of the set.

Jul 25th, 2000 13:26
Richard Heyes, Caroline Wise,


Whilst the value returned from a call to either mysql_fetch_row or 
mysql_fetch_array is an array, the result set returned by mysql_query() 
is not. Therefore reset(), an array function, will not work. 
Fortunately there is mysql_data_seek() that can perform a similar 
action:
mysql_data_seek($result_id, 0); // Where 0 is the row number.