Search code examples
phpmysqlsql-limit

PHP Query LIMIT DESC not working properly


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?


Solution

  • 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 :)