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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.