-1

I am trying to get a list of highscores (top 10) of players that played my game. Everything works except for one thing, the list isn't right. The first 10 people are correct, but when i go to page 2 the list isn't further going done.

Page 1

Page 2

Variables Explain

$gamemode = "Endless"
$filter = "Score"
$startNum = Page1 = 0, Page2 = 10
$maxlimit = 10

Query:

$query = "SELECT ID, Gamemode, Name, Score, ContainersSaved, TimePlayed, Date, ScorePerMinute
FROM $dbName . `highscore`
WHERE Gamemode='$gamemode'
ORDER by `$filter` DESC
LIMIT $startNum, $maxlimit";

Does anyone know what im doing wrong?

rvandoni
  • 3,297
  • 4
  • 32
  • 46
Jean-Paul
  • 380
  • 2
  • 9
  • 26

2 Answers2

1

If your Score field is varchar try: (or change it to INT)

$order=$filter;
if($filter=='Score') {
    $order="ABS($filter);
}
$query = "SELECT ID,Gamemode,Name,Score,ContainersSaved,TimePlayed,Date,ScorePerMinute FROM $dbName . `highscore` WHERE Gamemode='$gamemode' ORDER by $order DESC LIMIT $startNum, $maxlimit";
Imaginaerum
  • 769
  • 8
  • 22
  • If i do this i get an error : Error 500 Internal Server Error, also i think you forgot an " in your code? – Jean-Paul Jan 21 '15 at 13:20
0

I fixed it, i forgot to change the 'Score' field from varchar to an INT, so it was trying to Descend on string instead of INT.

Thanks to the tip Imaginaerum gave me :)

Jean-Paul
  • 380
  • 2
  • 9
  • 26