diff --git a/index.php b/index.php
index 44f8f31..256dc0d 100644
--- a/index.php
+++ b/index.php
@@ -3,8 +3,8 @@ session_start();
$conn = new mysqli("localhost","root","","breakout_db");
if($conn->connect_error){ die("DB Error"); }
-$isLoggedIn = isset($_SESSION['user']); // SUDAH DIPERBAIKI
-$username = $isLoggedIn ? htmlspecialchars($_SESSION['user']) : null; // SUDAH DIPERBAIKI
+$isLoggedIn = isset($_SESSION['user']);
+$username = $isLoggedIn ? htmlspecialchars($_SESSION['user']) : null;
?>
diff --git a/leaderboard.php b/leaderboard.php
index ae8faf0..982f10d 100644
--- a/leaderboard.php
+++ b/leaderboard.php
@@ -1,57 +1,126 @@
query("SELECT username, highscore FROM users ORDER BY highscore DESC LIMIT 10");
+$conn = new mysqli("localhost", "root", "", "breakout_db");
+if ($conn->connect_error) {
+ die("Connection failed: " . $conn->connect_error);
+}
-$isLoggedIn = isset($_SESSION['user']); // SUDAH DIPERBAIKI
-$username = $isLoggedIn ? htmlspecialchars($_SESSION['user']) : null; // SUDAH DIPERBAIKI
+$lb_easy = $conn->query("SELECT username, highscore_easy FROM users WHERE highscore_easy > 0 ORDER BY highscore_easy DESC LIMIT 10");
+
+$lb_medium = $conn->query("SELECT username, highscore_medium FROM users WHERE highscore_medium > 0 ORDER BY highscore_medium DESC LIMIT 10");
+
+$lb_hard = $conn->query("SELECT username, highscore_hard FROM users WHERE highscore_hard > 0 ORDER BY highscore_hard DESC LIMIT 10");
+
+$isLoggedIn = isset($_SESSION['user']);
?>
-
-Leaderboard
+
+
+ Leaderboard - Breakout Game
-
-
-
-
+
+
+
- Leaderboard
+ Hall of Fame
-<
-
-
-
-
- | Username |
- Highscore |
-
-
-
- fetch_assoc()) { ?>
-
- | = htmlspecialchars($r['username']) ?> |
- = htmlspecialchars($r['highscore']) ?> |
-
-
-
-
-
+
+
+
+
Easy Level
+
+
+
+ | Username |
+ Score |
+
+
+
+ num_rows > 0) {
+ while($r = $lb_easy->fetch_assoc()) {
+ echo "
+ | " . htmlspecialchars($r['username']) . " |
+ " . htmlspecialchars($r['highscore_easy']) . " |
+
";
+ }
+ } else {
+ echo "| No records yet |
";
+ }
+ ?>
+
+
+
-
⬅ Back
+
+
Medium Level
+
+
+
+ | Username |
+ Score |
+
+
+
+ num_rows > 0) {
+ while($r = $lb_medium->fetch_assoc()) {
+ echo "
+ | " . htmlspecialchars($r['username']) . " |
+ " . htmlspecialchars($r['highscore_medium']) . " |
+
";
+ }
+ } else {
+ echo "| No records yet |
";
+ }
+ ?>
+
+
+
+
+
+
Hard Level
+
+
+
+ | Username |
+ Score |
+
+
+
+ num_rows > 0) {
+ while($r = $lb_hard->fetch_assoc()) {
+ echo "
+ | " . htmlspecialchars($r['username']) . " |
+ " . htmlspecialchars($r['highscore_hard']) . " |
+
";
+ }
+ } else {
+ echo "| No records yet |
";
+ }
+ ?>
+
+
+
+
+
+ ⬅ Back to Game
\ No newline at end of file