diff --git a/answer.php b/answer.php index 21d8a87..6ad0363 100644 --- a/answer.php +++ b/answer.php @@ -60,7 +60,7 @@ if($uid == '') { } $old_high = $db->query('SELECT "score" FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', array($uid, $cid))['data'][0]['score']; - $new_high = round($old_high * 0.95 + $score * 0.05); + $new_high = $old_high == 0 ? $score : round($old_high * 0.95 + $score * 0.05); $db->query('UPDATE "Highscores" SET "score" = $1 WHERE "Users_ID" = $2 AND "Categories_ID" = $3', array($new_high, $uid, $cid)); diff --git a/highscores.php b/highscores.php index 2c72869..01a43a4 100644 --- a/highscores.php +++ b/highscores.php @@ -28,9 +28,7 @@ if($uid == '') { $cat = $category['name']; $score = $db->query('SELECT "score" FROM "Highscores" WHERE "Users_ID" = $1 AND "Categories_ID" = $2', array($uid, $cid))['data'][0]['score']; - if($score == null) { - $score = 0; - } + $score = $score == null ? 0 : +$score; $place = $db->query( 'SELECT COUNT (*) FROM "Highscores" WHERE "Categories_ID" = $1 AND "score" > $2',