Jump to content

[SOLVED] mySQL ORDER BY not working


Maximus

Recommended Posts

Hi, I am trying to retrieve 10 entries with the highest value in field "votes".

 

$result = mysql_query("SELECT * FROM `sites` ORDER BY `votes` ASC LIMIT 0,10");

while($g = mysql_fetch_array($result))
{
echo '<br>'.$g['name'].' - '.$g['votes'].' Votes</a>';
}

 

The code above displays ten entries, but doesn't but them in order from high to low.  I don't understand...

 

The output looks like this:

 

dsgdsg - 0 Votes

dgds - 0 Votes

omg lol - 0 Votes

gkjkfgs - 0 Votes

fhfd - 0 Votes

lhhgllk - 0 Votes

dfhjdfj - 2434 Votes

test - 5 Votes

gjdfd - 5765 Votes

fjdgdd- 64 Votes

 

Ignore the phony names, but rather focus on the order of the "votes"...its really weird.

Link to comment
https://forums.phpfreaks.com/topic/41360-solved-mysql-order-by-not-working/
Share on other sites

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.