Daevid,

I think there is only the initial connection (using mysql_query()), 
and the result set is saved to a variable.  This variable is then 
operated on by mysql_fetch_object().  My problem was that 
the internal pointer had exhausted its original array when I was 
calling it a second time, and I had to reset the pointer with 
mysql_data_seek().  With that function, I was able to reset the 
pointer working on that same object (the original result set), 
without having to hit the db again.

HTH, George


> -----Original Message-----
> From: Daevid Vincent [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, April 04, 2001 4:18 PM
> To: Mark Roedel; George Wright; [EMAIL PROTECTED]
> Subject: RE: [PHP] reusing MySQL results -- resetting mySQL 
> pointer with
> mysql_data_seek()
> 
> 
> Just my two cents here...
> 
> I could be mistaken, but wouldn't this method hit the database twice?
> 
> I would suggest you take your results the first time and 
> store them in an
> array or multidimensional array, then you can get to any 
> element at any time
> further down the page.
> 
> > -----Original Message-----
> > From: Mark Roedel [mailto:[EMAIL PROTECTED]]
> > Sent: Wednesday, April 04, 2001 7:52 AM
> > To: George Wright; [EMAIL PROTECTED]
> > Subject: RE: [PHP] reusing MySQL results
> >
> >
> > > -----Original Message-----
> > > From: George Wright [mailto:[EMAIL PROTECTED]]
> > > Sent: Wednesday, April 04, 2001 9:35 AM
> > > To: '[EMAIL PROTECTED]'
> > > 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
> 

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to