angelicatesvara07-crypto 25f5d864d3 leaderboard
2025-12-15 13:19:37 +07:00

74 lines
1.6 KiB
PHP

<?php
require_once 'db.php';
// TES KONEKSI
if (!$conn) {
die("DB connection failed");
}
$sql = "
SELECT username, difficulty, time_seconds
FROM leaderboard_sudoku
ORDER BY difficulty, time_seconds ASC
LIMIT 10
";
$result = $conn->query($sql);
?>
<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 ($result && $result->num_rows > 0): ?>
<?php while ($row = $result->fetch_assoc()): ?>
<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 endwhile; ?>
<?php else: ?>
<tr>
<td colspan="3">Belum ada data</td>
</tr>
<?php endif; ?>
</table>
</div>
<?php $conn->close(); ?>