Re: WHY need to query 2x to get results

From: Date: Tue, 22 Jul 2003 11:23:27 +0000
Subject: Re: WHY need to query 2x to get results
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-29393@lists.php.net to get a copy of this message
On Tuesday 22 July 2003 18:20, Ow Mun Heng wrote: > Hi, > > I have a code that goes like this. Scroll down to the "<----------" > sign. How come I need another $result = mysql_query($sql) at that location? > If I don't have it, the results coming out will only start printing from > the 2nd Row.. Omitting the 1st. > > Results as wanted > > row 1 value1 > row 2 value2 > row 3 value3 > > Getting this instead > > row 2 value2 > row 3 value3 > > ???? > > Pls Help. > > $result = mysql_query($sql); > > $num_results = mysql_num_rows($result); > > $row = mysql_fetch_row($result); The above line has gobbled up your 1st row of results and moved the result pointer onto the 2nd row. Use mysql_data_seek() to reset the pointer back to the 1st row. -- Jason Wong -> Gremlins Associates -> www.gremlins.biz Open Source Software Systems Integrators * Web Design & Hosting * Internet & Intranet Applications Development * ------------------------------------------ Search the list archives before you post http://marc.theaimsgroup.com/?l=php-db ------------------------------------------ /* Flights never leave from Gate #1 at any terminal in the world -- Murphy's Laws for Frequent Flyers n4 */

« previous php.db (#29393) next »