Jump to content

I Want To Grab 10 Rows And Order By Top 10?


Stalingrad

Recommended Posts

Hi! I have some PHP and MySQL code here. I am trying to set up this table displaying users scores. I want to grab from a table in a sepecific row and order the row by the top to bottom, but only the TOP 10. Like for example, lets say I wanted only 3 for this example to keep it simple. (even though I wnat 10, thisexample will keep things simple and not waste any time)... I have a table called "user".

Row Name:

id name score

1 julie 100

2 sam 80

3 james 35

 

I want to grab both the username AND the score, and order by the score, larger score to bottom. Just like I showed.

 

Here is my code:

 

if($table == "Avatar") {
$avq = "SELECT avatarcount FROM users";
echo "Top Scores<br><br>";
}

 

I appreciate any help! Thank you!

Link to comment
Share on other sites

Oh wait, it's ordering them by the first number, not the whole number... I'm getting this:

99

84

3455

 

How do I fix this one? Thanks. :s

 

Ah, I got it. It seems I didn't have the row set as "INT" in my database, it was set as "VARCHAR". Thank you for the help. It works fine now. ^^

Edited by Stalingrad
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.