leaderboard
This commit is contained in:
parent
4149a275fd
commit
6ba190ca85
23
load_leaderboard.php
Normal file
23
load_leaderboard.php
Normal file
@ -0,0 +1,23 @@
|
||||
<?php
|
||||
require 'db.php';
|
||||
|
||||
header('Content-Type: application/json');
|
||||
|
||||
try {
|
||||
$stmt = $pdo->query("
|
||||
SELECT u.id AS user_id, u.username, s.wins, s.losses
|
||||
FROM users u
|
||||
LEFT JOIN users_stats s ON s.user_id = u.id
|
||||
GROUP BY u.id
|
||||
ORDER BY s.wins DESC, s.losses ASC
|
||||
LIMIT 20
|
||||
");
|
||||
|
||||
$rows = $stmt->fetchAll();
|
||||
echo json_encode($rows);
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo json_encode([
|
||||
"error" => $e->getMessage()
|
||||
]);
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user