RE: [PHP-DB] Re-using a result set

From: Date: Thu, 11 Jan 2001 20:18:25 +0000
Subject: RE: [PHP-DB] Re-using a result set
Groups: php.db 
Request: Send a blank email to php-db+get-5809@lists.php.net to get a copy of this message
Try calling: mysql_data_seek($connection, 0); then looping through again. This should reset the row pointer to the first row so that you can go through again :) Sean -----Original Message----- From: TopFive [mailto:chris@topfive.com] Sent: Thursday, January 11, 2001 3:02 PM To: php-db@lists.php.net Subject: [PHP-DB] Re-using a result set Hello, everyone -- I'm new to the list, and to PHP. I own a very large, very active original humor website which currently consists of over 2000 HTML documents, and I'm converting it to a database-driven model which should reduce that amount to less than 100. I'm from an old school dBase/Clipper/FoxPro background, and thought this would be a snap, but a few little things have got me utterly stumped. For example, is there any way to re-use a query result set? I successfully run this query: $sql = "SELECT item_num, item FROM list_items"; $sql_result = mysql_query($sql,$connection) or die ("Couldn't get list!"); Then loop through the result set using: while ($row = (mysql_fetch_array($sql_result))) { // whatever } Later in the same document, I'd like to go back to that same result set and loop through it again, rather than having to make another identical query. Any ideas would be greatly appreciated. TIA, Chris White TopFive.com P.S. Julie Meloni -- nice to see you on the list! Your "PHP Essentials" was the first PHP book I bought and I recommend it very highly to anyone wanting to ramp up to a working knowledge of PHP as fast as possible. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net For additional commands, e-mail: php-db-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.db (#5809) next »