This repository has been archived on 2025-05-02. You can view files and clone it, but cannot push or open issues or pull requests.
Webtris/leaderboard.php
2019-11-02 22:10:36 +01:00

38 lines
1.3 KiB
PHP
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>Meilleurs scores - Webtris</title>
<link rel="icon" type="image/png" href="favicon.png">
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<h1>WEBTRIS</h1>
<table id="leaderboard">
<caption>MEILLEURS SCORES</caption>
<?php
include "db_connect.php";
try {
$db = new PDO("mysql:host=$DB_HOST;dbname=$DB_NAME;charset=utf8", $DB_USER, $DB_PASSWORD);
} catch (Exception $e) {
die('Erreur : ' . $e->getMessage());
}
$top10 = $db->query('SELECT player, score FROM `leaderboard` ORDER BY score DESC LIMIT 20;');
for ($i = 1; $row = $top10->fetch(); $i++) {
$score = number_format($row['score'], 0, ",", "");
echo ' <tr><th class="name">' . $i . '<td class="player">' . $row['player'] . '</td><td class="value">' . $score . "</td></tr>\n";
}
$top10->closeCursor();
$db->close();
?>
</table>
<div class="flex-container">
<div id="button-link">
<a href="settings.php" target="_blank">OPTIONS</a>
</div>
<div id="button-link">
<a href="index.php">REJOUER</a>
</div>
</div>
</body>
</html>