Re: first record not displayed
| From: | David Robley | Date: | Tue, 24 Jan 2006 07:19:41 +0000 |
| Subject: | Re: first record not displayed | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-41131@lists.php.net to get a copy of this message | ||
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.