By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,643 Members | 1,797 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,643 IT Pros & Developers. It's quick & easy.

Problem with while

P: n/a
I am doing the following statement to retrieve results:

$response = mysql_query("select * from preguntas where tema=$tema",
$db);
$row = mysql_fetch_array($response);
while($row = mysql_fetch_array($response))
{
echo('<font face="Tahoma" size="2">');
echo('<p align="left">');
echo($f .'- <a href="respuestas.php?id='. $row[id]. '">'
..$row[pregunta]. '</a>');
$f++;
}

I receive 2 items as a result. But if I check inside the DB, the result
should be 3 items....I am loosing the first record.

Any ideas about what could be wrong?

Regards,

Ezequiel

Jan 25 '07 #1
Share this Question
Share on Google+
1 Reply


P: n/a
zek2005 wrote:
I am doing the following statement to retrieve results:

$response = mysql_query("select * from preguntas where tema=$tema",
$db);
$row = mysql_fetch_array($response);
This fetches the first row
while($row = mysql_fetch_array($response))
This fetches the second (and subsequent) rows, throwing away the results
of the first (and previous) rows.
{
echo('<font face="Tahoma" size="2">');
echo('<p align="left">');
echo($f .'- <a href="respuestas.php?id='. $row[id]. '">'
.$row[pregunta]. '</a>');
$f++;
}

I receive 2 items as a result. But if I check inside the DB, the result
should be 3 items....I am loosing the first record.

Any ideas about what could be wrong?

Regards,

Ezequiel
Get rid of the first

$row = mysql_fetch_array($response);
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
js*******@attglobal.net
==================
Jan 25 '07 #2

This discussion thread is closed

Replies have been disabled for this discussion.