diff --git a/allhighscores.php b/allhighscores.php index b33ed79..c0ce8f2 100644 --- a/allhighscores.php +++ b/allhighscores.php @@ -35,7 +35,6 @@ if($cid == -1) { foreach($overview as $row) { $name = $row['name']; $score = $row['c_score']; - //$score = (isset($score) AND $score != NULL) ? ($row['score']) : -1; $place = $db->query('SELECT COUNT(*) FROM "Highscores" WHERE "score" > $1 AND "Categories_ID" = $2', array($score, $cid))['data'][0]['count'] + 1; $data[] = array('place' => $place, 'name' => $name, 'score' => $score); diff --git a/highscores.php b/highscores.php index a5e53d9..f0ae79d 100644 --- a/highscores.php +++ b/highscores.php @@ -18,7 +18,8 @@ if($uid == '') { ['data']['0']['exists'] == 'f') { $error = 15102; } else { - $score_all = $db->query('SELECT "highscore" FROM "Users" WHERE "ID" = $1', array($uid))['data'][0]['highscore']; + $score_all = $db->query('SELECT COALESCE("highscore", -1) as "highscore" + FROM "Users" WHERE "ID" = $1', array($uid))['data'][0]['highscore']; $all = $db->query('SELECT COUNT (*) FROM "Users"')['data'][0]['count']; $place_all = $db->query('SELECT COUNT (*) FROM "Users" WHERE "highscore" > $1', array($score_all))['data'][0]['count'] + 1; //get categories highscores @@ -26,13 +27,14 @@ if($uid == '') { foreach($categories as $category) { $cid = $category['ID']; $cat = $category['name']; - $score = $db->query('SELECT "score" FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', + $score = $db->query('SELECT COALSESCE("score", -1) as "score" + FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', array($uid, $cid))['data'][0]['score']; - if($score == null) { + /*if($score == null) { $score = 0; $db->query('UPDATE "Highscores" SET "score" = $1 WHERE "Users_ID" = $2 AND "Categories_ID" = $3', array($score, $uid, $cid)); - } + }*/ $place = $db->query( 'SELECT COUNT (*) FROM "Highscores" WHERE "Categories_ID" = $1 AND "score" > $2',