angelicatesvara07-crypto d27b2bf3f9 Leaderboard Fix
2025-12-15 19:57:21 +07:00

67 lines
1.5 KiB
PHP

<?php
require_once 'db.php';
$sql = "
SELECT username, difficulty, time_seconds
FROM leaderboard_sudoku
ORDER BY difficulty, time_seconds ASC
LIMIT 10
";
$stmt = $conn->query($sql);
$data = $stmt->fetchAll();
?>
<style>
.leaderboard {
background: #1e1e1e;
color: white;
padding: 20px;
border-radius: 10px;
width: 350px;
}
.leaderboard table {
width: 100%;
border-collapse: collapse;
}
.leaderboard th, .leaderboard td {
padding: 8px;
border-bottom: 1px solid #444;
text-align: center;
}
.leaderboard th {
background: #333;
}
</style>
<div class="leaderboard">
<h3>🏆 Leaderboard</h3>
<table>
<tr>
<th>User</th>
<th>Level</th>
<th>Time</th>
</tr>
<?php if (count($data) > 0): ?>
<?php foreach ($data as $row): ?>
<tr>
<td><?= htmlspecialchars($row['username']) ?></td>
<td><?= strtoupper($row['difficulty']) ?></td>
<td>
<?= sprintf(
"%02d:%02d",
floor($row['time_seconds'] / 60),
$row['time_seconds'] % 60
) ?>
</td>
</tr>
<?php endforeach; ?>
<?php else: ?>
<tr>
<td colspan="3">Belum ada data</td>
</tr>
<?php endif; ?>
</table>
</div>