Re: Fw: Retrieving records

From: Date: Wed, 02 Aug 2000 22:05:15 +0000
Subject: Re: Fw: Retrieving records
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-1499@lists.php.net to get a copy of this message
Danilo Meles wrote: > > > > Hi everyone; > > > > Please help me !!!! > > > I'm trying to output data from a table in my database, I've used the php > > > code as you can see below. But supose the table has 50 records, the code > > > above only retrieve 49 records. > > > <? > > > mysql_pconnect("host","user","password") > > > or die("Unable to connect to SQL server"); > > > mysql_select_db("pesquisa") or die("Unable to select database"); > > > $query="Select * from coleta order by id asc"; > > > $dados = mysql_query($query) or die("Select Failed!"); > > > $resp = mysql_fetch_array($dados); You fetch a row here from your results. You don't use it. > > > ?> > > > > > > <? > > > while($resp = mysql_fetch_array($dados)){ This loop starts by fetching another row, ignoring the first row you got above. Solution: Get rid of the first $resp line above. While() will terminate without executing the contents of the loop if $resp is NULL. You may get an error, though. You could also use a do ... loop if PHP supports it (never had the occasion to use it, so I don't know). -- O.

« previous php.windows (#1499) next »