Re: Fw: Retrieving records
| From: | Rich Cavanaugh | Date: | Wed, 02 Aug 2000 22:06:12 +0000 |
| Subject: | Re: Fw: Retrieving records | ||
| References: | 1 | Groups: | php.windows |
| Request: | Send a blank email to php-windows+get-1500@lists.php.net to get a copy of this message | ||
Ok, this is your code with my comments in php style comments:
<?
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";
// You perform your query on the next line.
$dados = mysql_query($query) or die("Select Failed!");
// Now you are advancing the internal row pointer by one and assigning
that row to $resp
$resp = mysql_fetch_array($dados);
?>
<?
// This while statement continues to advance the row pointer and
assigning it to $resp
// This is where your problem lies. You've already advanced it once, but
did nothing with the data
// To fix it you should get rid of the first $resp =
mysql_fetch_array($dados); (above)
while($resp = mysql_fetch_array($dados)){
?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Untitled</title>
</head>
<body bgcolor="White" leftmargin=0 topmargin=0>
<table cellspacing="2" cellpadding="2" border="0">
<tr>
<td><?echo $resp[pergunta];?></td>
<td><a href="link.php?id=<?echo
$resp[id];?>">Responder?</a></td>
</tr>
</table>
</body>
</html>
<?}?>
Hope this helps,
Rich
""Danilo Meles"" <dmeles@paraisonet.com.br> wrote in message
news:00f801c597d0$21f0d430$23cecac8@paraisonet...
> > > 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.
> > >
> > > what I'm doing wrong??? Can you help me???
> > >
> > > Thank's a lot !!
> > >
> > > Danilo Meles
> > >
> > > <?
> > > 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);
> > > ?>
> > >
> > > <?
> > > while($resp = mysql_fetch_array($dados)){
> > > ?>
> > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
> > >
> > > <html>
> > > <head>
> > > <title>Untitled</title>
> > > </head>
> > >
> > > <body bgcolor="White" leftmargin=0 topmargin=0>
> > > <table cellspacing="2" cellpadding="2"
> > > border="0">
> > > <tr>
> > > <td><?echo $resp[pergunta];?></td>
> > > <td><a href="link.php?id=<?echo
> > > $resp[id];?>">Responder?</a></td>
> > > </tr>
> > > </table>
> > > </body>
> > > </html>
> > > <?}?>
>
>
>
> --
> PHP Windows Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net
> For additional commands, e-mail: php-windows-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>