35 lines
957 B
PHP
35 lines
957 B
PHP
<?php
|
|
require_once 'includes/header.php';
|
|
require_once 'db/config.php';
|
|
|
|
// Fetch leaderboard data
|
|
$stmt = db()->query('SELECT u.name, l.score FROM leaderboard l JOIN users u ON l.user_id = u.id ORDER BY l.score DESC');
|
|
$leaderboard = $stmt->fetchAll();
|
|
|
|
?>
|
|
|
|
<div class="container">
|
|
<h1 class="text-center my-4">Leaderboard</h1>
|
|
<table class="table table-striped">
|
|
<thead>
|
|
<tr>
|
|
<th>Rank</th>
|
|
<th>User</th>
|
|
<th>Score</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php foreach ($leaderboard as $index => $row): ?>
|
|
<tr>
|
|
<td><?php echo $index + 1; ?></td>
|
|
<td><?php echo htmlspecialchars($row['name']); ?></td>
|
|
<td><?php echo $row['score']; ?></td>
|
|
</tr>
|
|
<?php endforeach; ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<?php
|
|
require_once 'includes/footer.php';
|
|
?>
|