RE: [PHP] reusing MySQL results

From: Date: Wed, 04 Apr 2001 14:47:48 +0000
Subject: RE: [PHP] reusing MySQL results
Groups: php.general 
Request: Send a blank email to php-general+get-47058@lists.php.net to get a copy of this message
use mysql_data_seek() just like you'd use reset() on an array. from php.net : "mysql_data_seek() moves the internal row pointer of the MySQL result associated with the specified result identifier to point to the specified row number. The next call to mysql_fetch_row() would return that row. " -----Original Message----- From: George Wright [mailto:GWright@mhiweb.com] Sent: Wednesday, April 04, 2001 10:35 AM To: 'php-general@lists.php.net' Subject: [PHP] reusing MySQL results Hi All, I have a page with two forms. Both forms have drop-down option lists that are populated by a the same query. The query and db connection are all done before either form is introduced (this is the select statement, mysql_pconnect(), mysql_select_db(), and mysql_query()). I am using a while loop to build the options. The loop "engine" is mysql_fetch_object(), which writes out the values inside of option tags. Everything works fine the first time around, but when I call the query result for the second time, it's as if there are no rows to return so nothing is written out. No errors are being thrown. I know the resultant query object still exists, because I can access some of its properties (e.g.: mysql_num_rows has a value when it is called at this same place in the code as the second loop set). One caveat: This code DOES work if, just before the second call to build the second set of options, I resend the query (again using mysql_query()). I would think that looping on the object the first time should only read from it and not otherwise change it. Why am I unable to reuse this object in a second mysql_fetch_object() without resending the query? I have tried distinguishing the variable names that I set the results to for each loop and this doesn't seem to make a difference. Running PHP 4.0.4, MySQL 3.23.22-beta on Win2K. Thanks, George -- PHP General Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net For additional commands, e-mail: php-general-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.general (#47058) next »