Re: Re-using a result set

From: Date: Thu, 11 Jan 2001 20:24:37 +0000
Subject: Re: Re-using a result set
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-5808@lists.php.net to get a copy of this message
Sure, just do: mysql_data_seek($sql_result,0); before you get to your while() the second time. Hope this helps, Joe TopFive wrote: > 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 (#5808) next »