first record not displayed
am 23.01.2006 21:31:06 von Paul Bern
Hi,
I have the feeling I'm missing something very obvious here, but it's =
driving me nuts! Using this select statement:
$result =3D mysql_query("SELECT * FROM latlong ",$link);
$nrows =3D mysql_num_rows($result);
and either of these to display the results:
for ($j=3D0; $rec=3Dmysql_fetch_array($result); $j++){
print "j=3D$j id=3D{$rec["id"]} seq=3D{$rec["seq"]}\n"; =20
}
while($row =3D mysql_fetch_array($result)){
echo "id=3D{$row["id"]} seq=3D{$row["seq"]} \n";
}
The very first record gets dropped/not displayed. The number of records =
returned ($nrows) matches what I get from MySQL and the first record gets =
displayed (using PHPMyAdmin). Even if I change the select to pull only =
certain records, the very first one does not get displayed.
Can anyone shed any light on this for me?
Thanks!
Paul
************************************************************ ***************=
*****************************
Paul H. Bern, Ph.D.
Numeric Data Services Librarian The only thing worse than not
352 Bird Library getting what you =
wanted
222 Waverly Ave. is getting what you =
asked for.
Syracuse, NY 13244
315-443-1352
http://library.syr.edu/information/mgi/nds
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: first record not displayed
am 23.01.2006 23:09:39 von Gerry Danen
Paul,
Is $link relevant?
Have you run a repair on the table?
The for loop seems odd to me, but I use the while construct exclusively.
Adapted to one of my tables, this worked correctly:
$result =3D mysql_query("SELECT * FROM photos ");
while($row =3D mysql_fetch_array($result)){
echo "id=3D{$row["p_id"]} seq=3D{$row["p_desc"]}
\n";
}
On 1/23/06, Paul Bern wrote:
> Hi,
>
> I have the feeling I'm missing something very obvious here, but it's driv=
ing me nuts! Using this select statement:
>
> $result =3D mysql_query("SELECT * FROM latlong ",$link);
> $nrows =3D mysql_num_rows($result);
>
>
> and either of these to display the results:
>
> for ($j=3D0; $rec=3Dmysql_fetch_array($result); $j++){
> print "j=3D$j id=3D{$rec["id"]} seq=3D{$rec["seq"]}\n";
> }
>
>
> while($row =3D mysql_fetch_array($result)){
> echo "id=3D{$row["id"]} seq=3D{$row["seq"]} \n";
> }
>
> The very first record gets dropped/not displayed. The number of records =
returned ($nrows) matches what I get from MySQL and the first record gets =
displayed (using PHPMyAdmin). Even if I change the select to pull only cer=
tain records, the very first one does not get displayed.
>
> Can anyone shed any light on this for me?
>
> Thanks!
>
> Paul
>
>
>
> ************************************************************ *************=
*******************************
> Paul H. Bern, Ph.D.
> Numeric Data Services Librarian The only thing worse than not
> 352 Bird Library getting what you w=
anted
> 222 Waverly Ave. is getting what you a=
sked for.
> Syracuse, NY 13244
> 315-443-1352
> http://library.syr.edu/information/mgi/nds
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
--
Gerry
http://portal.danen.org/
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Re: first record not displayed
am 24.01.2006 08:19:41 von robleyd
Paul Bern wrote:
> Hi,
>
> I have the feeling I'm missing something very obvious here, but it's
> driving me nuts! Using this select statement:
>
> $result = mysql_query("SELECT * FROM latlong ",$link);
> $nrows = mysql_num_rows($result);
>
>
> and either of these to display the results:
>
> for ($j=0; $rec=mysql_fetch_array($result); $j++){
> print "j=$j id={$rec["id"]} seq={$rec["seq"]}\n";
> }
>
>
> while($row = mysql_fetch_array($result)){
> echo "id={$row["id"]} seq={$row["seq"]} \n";
> }
>
> The very first record gets dropped/not displayed. The number of records
> returned ($nrows) matches what I get from MySQL and the first record gets
> displayed (using PHPMyAdmin). Even if I change the select to pull only
> certain records, the very first one does not get displayed.
>
> Can anyone shed any light on this for me?
>
> Thanks!
>
> Paul
That sounds like you may somewhere have a mysql_fetch_array() from which
you are not using the result; thsat ill fetch the first record, and if you
then start using the data from a "while($row = mysql_fetch_array" it will
start with the second record.
Something looks odd about your for loop, but my brain is a bit tired at the
moment and I can't pinpoint it :-)
Cheers
--
David Robley
This library isn't safe - I just stumbled on an idea.
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php