Compare commits

..

No commits in common. "2282f020050ef4f967d6f59b95a8f21cf372af10" and "71e7f7a48e323536b59f1c4d5ac5221a0ff8f185" have entirely different histories.

3 changed files with 28 additions and 112 deletions

View File

@ -1,29 +1,17 @@
<?php <?php
session_start(); // session_start();
require_once "config/db.php"; // require_once "config/db.php";
$sql= "SELECT username, score // $sql_leaderbord = "SELECT u.username, c.poin FROM characters c JOIN users u ON u.user_id = c.user_id ORDER BY c.poin DESC LIMIT 10 ";
FROM users
ORDER BY score DESC
LIMIT 10";
$nama = $_SESSION['username'];
$score = 0;
$getscore = "SELECT score FROM users WHERE username ='$nama'"; // $result = $db ->query($sql_leaderbord);
$result_me = mysqli_query($db,$getscore);
if ($result_me && mysqli_num_rows($result_me)>0){ // $leaderboard=[];
$row = mysqli_fetch_assoc($result_me); // if($result&&$result -> num_rows >0){
$score = $row['score']; // while($row = $result->fetch_assoc()){
} // $leaderboard[]=$row;
// }
// }
$result = mysqli_query($db, $sql);
$leaderboard = [];
if($result){
$leaderboard = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
?> ?>
@ -41,9 +29,9 @@ if($result){
<div class="container-board"> <div class="container-board">
<div class="chara"> <div class="chara">
<div class="menu"> <div class="menu">
<h1 style="text-align: center;"><?php echo $nama; ?></h1> <h1 style="text-align: center;">Matthew as Knight</h1>
</div> </div>
<h1 style="text-align: center;"> <?php echo $score; ?> </h1> <h1 style="text-align: center;">150pts</h1>
<div class="character"> <div class="character">
<img src="assets/Design/KnightPixLE.png" alt="knight"> <img src="assets/Design/KnightPixLE.png" alt="knight">
</div> </div>
@ -58,26 +46,25 @@ if($result){
</tr> </tr>
</thead> </thead>
<tbody> <tbody>
<?php <!-- <?php
$peringkat = 1; $peringkat = 1;
if (!empty($leaderboard)) {
foreach ($leaderboard as $pemain) : foreach ($leaderboard as $pemain) :
?> ?>
<tr>
<td><?php echo $peringkat; ?></td> <tr>
<td><?php echo htmlspecialchars($pemain['username']); ?></td> <td><?php echo $peringkat; ?></td>
<td><?php echo htmlspecialchars($pemain['username']); ?></td>
<td><?php echo $pemain['score']; ?> PTS</td> <td><?php echo $pemain['poin']; ?> PTS</td>
</tr> </tr>
<?php <?php
$peringkat++; $peringkat++;
endforeach; endforeach;
} else {
// Jika data kosong if (empty($leaderboard)) {
echo '<tr><td colspan="3" style="text-align: center;">Belum ada pemain</td></tr>'; echo '<tr><td colspan="3" style="text-align: center;">Belum ada pemain</td></tr>';
} }
?> ?> -->
</tbody> </tbody>
</table> </table>
</div> </div>

View File

@ -32,7 +32,7 @@ if(isset($_POST['register'])){
$new_user_id =$db-> insert_id; $new_user_id =$db-> insert_id;
$sql_char = "INSERT INTO users (user_id, name, score) VALUES (?, ?, 0)"; $sql_char = "INSERT INTO users (user_id, name, poin) VALUES (?, ?, 0)";
$stmt_char = $db->prepare($sql_char); $stmt_char = $db->prepare($sql_char);
$stmt_char->bind_param("is", $new_user_id, $username); $stmt_char->bind_param("is", $new_user_id, $username);

View File

@ -1,71 +0,0 @@
-- phpMyAdmin SQL Dump
-- version 5.2.3
-- https://www.phpmyadmin.net/
--
-- Host: db:3306
-- Generation Time: Nov 25, 2025 at 09:57 AM
-- Server version: 8.0.44
-- PHP Version: 8.3.26
SET SQL_MODE = "NO_AUTO_VALUE_ON_ZERO";
START TRANSACTION;
SET time_zone = "+00:00";
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8mb4 */;
--
-- Database: `codebeater`
--
-- --------------------------------------------------------
--
-- Table structure for table `users`
--
CREATE TABLE `users` (
`id` int NOT NULL,
`username` varchar(50) NOT NULL,
`email` varchar(100) NOT NULL,
`password` varchar(255) NOT NULL,
`score` int NOT NULL DEFAULT '0'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci;
--
-- Dumping data for table `users`
--
INSERT INTO `users` (`id`, `username`, `email`, `password`, `score`) VALUES
(1, 'bram', 'bahlil@gmail.com', '$2y$10$tOKCS5lO0/lRUW9c.VmsAeMu1M5LxO9F2lq/44yLk3Dl7FvmFUWEu', 100),
(4, 'bahlil', 'bahlil1@gmail.com', '$2y$10$qmU02E22qB6MD5RR8Bopi.nBI38jk2mOht2SHnXb64m30fpyg8cf6', 0);
--
-- Indexes for dumped tables
--
--
-- Indexes for table `users`
--
ALTER TABLE `users`
ADD PRIMARY KEY (`id`),
ADD UNIQUE KEY `username` (`username`),
ADD UNIQUE KEY `email` (`email`);
--
-- AUTO_INCREMENT for dumped tables
--
--
-- AUTO_INCREMENT for table `users`
--
ALTER TABLE `users`
MODIFY `id` int NOT NULL AUTO_INCREMENT, AUTO_INCREMENT=5;
COMMIT;
/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */;
/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;