Jump to content

missing 1st row of a mysql table


unistake

Recommended Posts

Hi all,

 

I am trying to display all the rows in a mysql table i have. - 4 at the moment.

The last 3 rows are showing no problem but the first one is not being displayed.

 

The code I am using is

 

$sql = "SELECT * FROM sales ORDER BY id DESC";

$result = mysqli_query($cxn,$sql)
or die ("Cant execute query");
$num = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result);
$counter=1;

echo "$num aircraft were found";
while ($row = mysqli_fetch_assoc($result)) {
extract($row);
        echo "$id, $details<br>";
}

 

Thanks for your help.

Link to comment
https://forums.phpfreaks.com/topic/208317-missing-1st-row-of-a-mysql-table/
Share on other sites

Edit: Basically the same as above ^^^^

missing 1st row of a mysql table

 

That's because your code is fetching and discarding the first row in the result set -

$num = mysqli_num_rows($result);
$row = mysqli_fetch_assoc($result); // ****** you are fetching and discarding this row *******
$counter=1;

 

Why do you have that line in your code ^^^^^

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.