167 lines
4.2 KiB
PHP
167 lines
4.2 KiB
PHP
<?php
|
|
session_start();
|
|
$conn = new mysqli("localhost","root","","breakout_db");
|
|
$lb = $conn->query("SELECT username, highscore FROM users ORDER BY highscore DESC LIMIT 10");
|
|
|
|
$isLoggedIn = isset($_SESSION['username']);
|
|
$username = $isLoggedIn ? htmlspecialchars($_SESSION['username']) : null;
|
|
?>
|
|
<!DOCTYPE html>
|
|
<html lang="en">
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<title>Leaderboard</title>
|
|
|
|
<!-- Font & Icons -->
|
|
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;600;700&display=swap" rel="stylesheet">
|
|
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
|
|
|
|
<style>
|
|
body {
|
|
font-family: 'Poppins', sans-serif;
|
|
margin: 0;
|
|
padding: 20px;
|
|
background: radial-gradient(circle at top, #6a85f1, #4834d4);
|
|
color: white;
|
|
text-align: center;
|
|
}
|
|
|
|
h2 {
|
|
font-size: 2.5rem;
|
|
margin-top: 20px;
|
|
text-shadow: 3px 3px 10px rgba(0,0,0,0.4);
|
|
}
|
|
|
|
/* ==== GLASS CONTAINER ==== */
|
|
.board-container {
|
|
margin: 25px auto;
|
|
width: 95%;
|
|
max-width: 650px;
|
|
background: rgba(255,255,255,0.10);
|
|
padding: 25px;
|
|
border-radius: 18px;
|
|
backdrop-filter: blur(12px);
|
|
border: 1px solid rgba(255,255,255,0.25);
|
|
box-shadow: 0px 10px 25px rgba(0,0,0,0.25);
|
|
}
|
|
|
|
table {
|
|
width: 100%;
|
|
border-collapse: collapse;
|
|
color: white;
|
|
border-radius: 12px;
|
|
overflow: hidden;
|
|
}
|
|
|
|
th {
|
|
background: rgba(255,255,255,0.2);
|
|
padding: 12px;
|
|
font-weight: 600;
|
|
letter-spacing: 1px;
|
|
}
|
|
|
|
td {
|
|
padding: 12px;
|
|
background: rgba(255,255,255,0.07);
|
|
border-bottom: 1px solid rgba(255,255,255,0.15);
|
|
}
|
|
|
|
tr:nth-child(even) td {
|
|
background: rgba(255,255,255,0.12);
|
|
}
|
|
|
|
tr:hover td {
|
|
background: rgba(255,255,255,0.22);
|
|
transition: 0.25s;
|
|
}
|
|
|
|
/* ==== BUTTONS ==== */
|
|
.back-button {
|
|
display: inline-block;
|
|
margin-top: 25px;
|
|
padding: 10px 22px;
|
|
background: linear-gradient(45deg, #28a745, #21c064);
|
|
border-radius: 25px;
|
|
color: white;
|
|
font-weight: bold;
|
|
text-decoration: none;
|
|
font-size: 1rem;
|
|
box-shadow: 0px 5px 15px rgba(0,0,0,0.25);
|
|
transition: 0.25s ease;
|
|
}
|
|
|
|
.back-button:hover {
|
|
transform: scale(1.05);
|
|
box-shadow: 0px 7px 18px rgba(0,0,0,0.45);
|
|
}
|
|
|
|
/* Menu on top (Optional same style as index) */
|
|
.menu {
|
|
display: flex;
|
|
justify-content: center;
|
|
gap: 15px;
|
|
margin-bottom: 10px;
|
|
flex-wrap: wrap;
|
|
}
|
|
|
|
.menu a {
|
|
padding: 10px 18px;
|
|
background: rgba(255,255,255,0.18);
|
|
border-radius: 30px;
|
|
color: #fff;
|
|
text-decoration: none;
|
|
backdrop-filter: blur(10px);
|
|
border: 1px solid rgba(255,255,255,0.3);
|
|
transition: 0.3s ease;
|
|
display: flex;
|
|
align-items: center;
|
|
gap: 7px;
|
|
}
|
|
|
|
.menu a:hover {
|
|
background: rgba(255,255,255,0.35);
|
|
transform: translateY(-3px);
|
|
}
|
|
|
|
</style>
|
|
</head>
|
|
<body>
|
|
|
|
<h2><i class="fas fa-trophy"></i> Leaderboard</h2>
|
|
|
|
<!-- MENU (Same style as index) -->
|
|
<div class="menu">
|
|
<a href="index.php"><i class="fas fa-home"></i> Home</a>
|
|
|
|
<?php if($isLoggedIn): ?>
|
|
<a href="logout.php"><i class="fas fa-right-from-bracket"></i> Logout</a>
|
|
<?php else: ?>
|
|
<a href="login.php"><i class="fas fa-sign-in-alt"></i> Logout</a>
|
|
<?php endif; ?>
|
|
</div>
|
|
|
|
<!-- TABLE -->
|
|
<div class="board-container">
|
|
<table>
|
|
<thead>
|
|
<tr>
|
|
<th>Username</th>
|
|
<th>Highscore</th>
|
|
</tr>
|
|
</thead>
|
|
<tbody>
|
|
<?php while($r = $lb->fetch_assoc()) { ?>
|
|
<tr>
|
|
<td><?= htmlspecialchars($r['username']) ?></td>
|
|
<td><?= htmlspecialchars($r['highscore']) ?></td>
|
|
</tr>
|
|
<?php } ?>
|
|
</tbody>
|
|
</table>
|
|
</div>
|
|
|
|
<a href="index.php" class="back-button">⬅ Back</a>
|
|
|
|
</body>
|
|
</html>
|