Re: select statement more than once using fetchInto

From: Date: Sun, 09 Jun 2002 14:00:21 +0000
Subject: Re: select statement more than once using fetchInto
References: 1  Groups: php.pear.dev 
Request: Send a blank email to pear-dev+get-6813@lists.php.net to get a copy of this message
electroteque wrote: > > hi i am have multiple select boxes populated from mysql which i would like > to show more than once , i have seen somewhere that mysql_data_seek($result, > 0 ); will do the job and have checked that fetchInto has this function > within it, and will allow to reset the while loop of the select and select > the same query again , > > i am trying > > while ($sample = $result->fetchRow(DB_FETCHMODE_ASSOC) ) > { > // ...do some other stuff... > } > > while ($result->fetchInto($sample,DB_FETCHMODE_ASSOC) ) > { > // ...do some other stuff... > } > it doesnt seem to be working what seems to be the problem ? > The cursor isn't automatically reset when you reach the last row. Try this code instead: while ($sample = $result->fetchRow(DB_FETCHMODE_ASSCO)) { .... } $i = 0; while ($sample = $result->fetchRow(DB_FETCHMODE_ASSOC, $i++)) { } Tomas V.V.Cox

« previous php.pear.dev (#6813) next »