Jump to content

incorrect results from mysql_fetch_array loop


tHud

Recommended Posts

 

Currently I have 5 entries in my table.

 

Entring this query displays all five in the correct order.

 

SELECT * FROM products ORDER BY count DESC LIMIT 16

 

 

 

However, using this code, the first result is omitted and the last four are displayed.

 

 

$query="SELECT * FROM products ORDER BY count DESC LIMIT 16";
$result = mysql_query($query);
$row = mysql_fetch_array($result);

echo '<div>';
while ($row = mysql_fetch_array($result))
	{
	echo '<div>'.$row[product].'</div> <div>'.$row[count].'</div>';
	}
echo '</div>';

 

Can someone help me find my error?

Thanks :)

I don't know why. I guess it's code I routinely paste.  :-[

 

However, I knew that I had read something about that in these forums but I was unable to find it due to the search function being unavailable.

 

It clearly shows a fundamental misunderstanding on my part.  I won't make that mistake again!

 

Thank you AbraCadaver. :D

 

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.