From 5757c7eb92a76eeb120f9094cc6c017494f0f728 Mon Sep 17 00:00:00 2001 From: Leander Date: Thu, 20 Apr 2017 09:31:22 +0200 Subject: [PATCH] T201704200931 --- allhighscores.php | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/allhighscores.php b/allhighscores.php index 18d8a5e..c4b3409 100644 --- a/allhighscores.php +++ b/allhighscores.php @@ -17,7 +17,7 @@ $db = new Database(); if($cid == -1) { $overview = $db->query('SELECT "name", "highscore" FROM "Users" ORDER BY "highscore" DESC LIMIT $1 OFFSET $2', array($limit, $offset))['data']; - foreach ($overview as $row) { + 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'] + 1; @@ -29,13 +29,20 @@ if($cid == -1) { WHERE h."Categories_ID" = $1 ORDER BY h."score" DESC LIMIT $2 OFFSET $3', array($cid, $limit, $offset))['data']; - foreach ($overview as $row) { + foreach($overview as $row) { $name = $row['name']; $score = $row['score']; $place = $db->query('SELECT COUNT(*) FROM "Highscores" WHERE "score" > $1 AND "Categories_ID" = $2', - array($score, $cid))['data'][0]['count'] + 1; + array($score, $cid))['data'][0]['count'] + 1; $data[] = array('place' => $place, 'name' => $name, 'score' => $score); } + $all_cat_highscores = $db->query('SELECT COUNT(*) FROM "Highscores" WHERE "Categories_ID" = $1', array($cid)) + ['data'][0]['count']; + $all_users = $db->query('SELECT "ID" FROM "Users"')['data']; + foreach($all_users as $user) { + //if($db->query('SELECT exists FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', + // array($user['id']))); + } } $response = Database::create_response($data, $error);