T201704101316
This commit is contained in:
25
allhighscores.php
Normal file
25
allhighscores.php
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* Created by PhpStorm.
|
||||||
|
* User: leanderschmedemann
|
||||||
|
* Date: 10.04.17
|
||||||
|
* Time: 13:24
|
||||||
|
*/
|
||||||
|
|
||||||
|
require_once('includes.inc.php');
|
||||||
|
$data = '';
|
||||||
|
$error = 0;
|
||||||
|
$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'];
|
||||||
|
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'];
|
||||||
|
$data[] = array('place' => $place, 'name' => $name, 'score' => $score);
|
||||||
|
}
|
||||||
|
|
||||||
|
$response = Database::create_response($data, $error);
|
||||||
|
print_r($response);
|
||||||
Reference in New Issue
Block a user