Possible Duplicate:
How to reset mysql pointer back to the first row in PHP?
I have 2 while loops in my PHP script that processes a list of data from a database.
$results = mysql_query("SELECT * FROM myTable");
while ($result = mysql_fetch_object($results)) {
// do stuff
}
reset($results);
while ($result = mysql_fetch_object($results)) {
// do some more stuff
}
However, the reset() function is not resetting my pointer within the MySQL resource. In fact, it generates an error:
“Warning: reset() [function.reset]: Passed variable is not an array or
object in /home/cs179_team13/public_html/timeTests/results.php on
line 133.”
Why? How do I reset a PHP pointer for a MySQL resource?
You can use the function
mysql_data_seek.bool mysql_data_seek ( resource $result , int $row_number )More information can be a found at http://www.php.net/manual/en/function.mysql-data-seek.php.