From 25f5d864d354758f826b561a951430f72e02a591 Mon Sep 17 00:00:00 2001 From: angelicatesvara07-crypto Date: Mon, 15 Dec 2025 13:19:37 +0700 Subject: [PATCH] leaderboard --- Background.jpg | Bin 0 -> 737 bytes Sudoku.php | 58 +++++++++++++++++++------------------ leaderboard.php | 74 ++++++++++++++++++++++++++++++++++++++++++++++++ save_scoee.php | 13 +++++++++ sudoku.sql | 9 ++++++ 5 files changed, 127 insertions(+), 27 deletions(-) create mode 100644 Background.jpg create mode 100644 leaderboard.php create mode 100644 save_scoee.php diff --git a/Background.jpg b/Background.jpg new file mode 100644 index 0000000000000000000000000000000000000000..a802b9daffdbc82630f71f371133922812d83013 GIT binary patch literal 737 zcmex=^lOiET&UP@Y7ModgWM?qOlT~kX_QeM|USHnP6LsJ7}2qQZ?I~NC+Fc+7w zhLo6;2Fc+60R}-1Mtg?W%#2D5OoEKef{g! - - - - Sudoku - - - Sudoku @@ -32,17 +23,15 @@ if (!isset($_SESSION['username'])) { } body { - font-family: 'Roboto', 'Segoe UI', sans-serif; - background-color: var(--bg-color); - color: var(--text-color); - margin: 0; - padding: 0; - height: 100vh; - display: flex; - justify-content: center; - align-items: center; - overflow: hidden; - } + font-family: 'Roboto', 'Segoe UI', sans-serif; + background: url("Background.jpg") no-repeat center center fixed; + background-size: cover; + color: var(--text-color); + margin: 0; + height: 100vh; + overflow: hidden; +} + .screen { display: none; @@ -52,7 +41,7 @@ if (!isset($_SESSION['username'])) { width: 100%; height: 100%; position: absolute; - background-color: var(--bg-color); + background-color: transparent; animation: fadeIn 0.3s ease-in-out; } @@ -385,12 +374,17 @@ if (!isset($_SESSION['username'])) { +
+ Logo +
Sudoku
+ + + + +
-
- Logo -
Sudoku
- -
Pilih Tingkat Kesulitan
@@ -730,7 +724,8 @@ if (!isset($_SESSION['username'])) { } stopTimer(); - + saveScore(); + let diffText = document.getElementById('difficulty-label').innerText; let timeText = document.getElementById("timer-label").innerText; @@ -797,6 +792,15 @@ if (!isset($_SESSION['username'])) { if (b[i][j] != 0) { b[i][j] = 0; count--; } } } + + function saveScore() { + fetch("save_score.php", { + method: "POST", + headers: { "Content-Type": "application/x-www-form-urlencoded" }, + body: `difficulty=${currentDifficulty}&time=${secondsElapsed}` + }); +} + \ No newline at end of file diff --git a/leaderboard.php b/leaderboard.php new file mode 100644 index 0000000..b5f0958 --- /dev/null +++ b/leaderboard.php @@ -0,0 +1,74 @@ +query($sql); +?> + + + +
+

🏆 Leaderboard

+ + + + + + + + + num_rows > 0): ?> + fetch_assoc()): ?> + + + + + + + + + + + +
UserLevelTime
+ +
Belum ada data
+
+ +close(); ?> + \ No newline at end of file diff --git a/save_scoee.php b/save_scoee.php new file mode 100644 index 0000000..7e77f43 --- /dev/null +++ b/save_scoee.php @@ -0,0 +1,13 @@ +prepare("INSERT INTO leaderboard_sudoku (username, difficulty, time_seconds) VALUES (?, ?, ?)"); +$stmt->bind_param("ssi", $username, $difficulty, $time); +$stmt->execute(); diff --git a/sudoku.sql b/sudoku.sql index 37f3859..ea8b819 100644 --- a/sudoku.sql +++ b/sudoku.sql @@ -63,6 +63,15 @@ ALTER TABLE `users` -- ALTER TABLE `users` MODIFY `id` int(11) NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=7; + + CREATE TABLE leaderboard_sudoku ( + id INT AUTO_INCREMENT PRIMARY KEY, + username VARCHAR(50), + difficulty VARCHAR(10), + time_seconds INT, + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP +); + COMMIT; /*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;