RE: [PHP] reusing MySQL results - SOLVED

From: Date: Wed, 04 Apr 2001 14:58:07 +0000
Subject: RE: [PHP] reusing MySQL results - SOLVED
Groups: php.general 
Request: Send a blank email to php-general+get-47067@lists.php.net to get a copy of this message
Excellent. Thanks for everyone's response. I put: mysql_data_seek($result_Section, 0); just ahead of the second while loop and it works perfectly. Thanks again, George > -----Original Message----- > From: Mark Roedel [mailto:MarkRoedel@letu.edu] > Sent: Wednesday, April 04, 2001 10:52 AM > To: George Wright; php-general@lists.php.net > Subject: RE: [PHP] reusing MySQL results > > > > -----Original Message----- > > From: George Wright [mailto:GWright@mhiweb.com] > > Sent: Wednesday, April 04, 2001 9: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. > > Mysql_data_seek() is your friend. > > PHP has an internal pointer that it maintains as you move through your > result set. At the end of your mysql_fetch_object while loop, that > pointer is located at the end of the result set. > > Mysql_data_seek() is the means for you to "rewind" that pointer to the > any specified row, including the first, of the result set. > > See > > http://php.net/manual/en/function.mysql-data-seek.php > > for more information, including sample code. > > > --- > Mark Roedel (roedelm@letu.edu) || "There cannot be a crisis > next week. > Systems Programmer / WebMaster || My schedule is already full." > LeTourneau University || -- > Henry Kissinger >

« previous php.general (#47067) next »