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!

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. ^^

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.