diff --git a/allhighscores.php b/allhighscores.php index 5ceb625..3d00386 100644 --- a/allhighscores.php +++ b/allhighscores.php @@ -13,11 +13,12 @@ $limit = isset($_GET['limit']) ? $_GET['limit'] : 10; $offset = isset($_GET['offset']) ? $_GET['offset'] : 0; $db = new Database(); -$overview = $db->query('SELECT "name", "highscore" FROM "Users" LIMIT $1 OFFSET $2', array($limit, $offset))['data']; +$overview = $db->query('SELECT "name", "highscore" FROM "Users" LIMIT $1 OFFSET $2 + ORDER BY "highscore" DESC', array($limit, $offset))['data']; foreach($overview as $row) { $name = $row['name']; $score = $row['highscore']; - $place = $db->query('SELECT COUNT(*) FROM "Users" WHERE "highscore" > $1', array($score))['data'][0]['count']; + $place = $db->query('SELECT COUNT(*) FROM "Users" WHERE "highscore" > $1', array($score))['data'][0]['count'] + 1; $data[] = array('place' => $place, 'name' => $name, 'score' => $score); }