Compare commits
No commits in common. "2282f020050ef4f967d6f59b95a8f21cf372af10" and "71e7f7a48e323536b59f1c4d5ac5221a0ff8f185" have entirely different histories.
2282f02005
...
71e7f7a48e
@ -1,29 +1,17 @@
|
||||
<?php
|
||||
session_start();
|
||||
require_once "config/db.php";
|
||||
// session_start();
|
||||
// require_once "config/db.php";
|
||||
|
||||
$sql= "SELECT username, score
|
||||
FROM users
|
||||
ORDER BY score DESC
|
||||
LIMIT 10";
|
||||
$nama = $_SESSION['username'];
|
||||
$score = 0;
|
||||
// $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 ";
|
||||
|
||||
$getscore = "SELECT score FROM users WHERE username ='$nama'";
|
||||
$result_me = mysqli_query($db,$getscore);
|
||||
// $result = $db ->query($sql_leaderbord);
|
||||
|
||||
if ($result_me && mysqli_num_rows($result_me)>0){
|
||||
$row = mysqli_fetch_assoc($result_me);
|
||||
$score = $row['score'];
|
||||
}
|
||||
|
||||
|
||||
$result = mysqli_query($db, $sql);
|
||||
$leaderboard = [];
|
||||
|
||||
if($result){
|
||||
$leaderboard = mysqli_fetch_all($result, MYSQLI_ASSOC);
|
||||
}
|
||||
// $leaderboard=[];
|
||||
// if($result&&$result -> num_rows >0){
|
||||
// while($row = $result->fetch_assoc()){
|
||||
// $leaderboard[]=$row;
|
||||
// }
|
||||
// }
|
||||
|
||||
?>
|
||||
|
||||
@ -41,9 +29,9 @@ if($result){
|
||||
<div class="container-board">
|
||||
<div class="chara">
|
||||
<div class="menu">
|
||||
<h1 style="text-align: center;"><?php echo $nama; ?></h1>
|
||||
<h1 style="text-align: center;">Matthew as Knight</h1>
|
||||
</div>
|
||||
<h1 style="text-align: center;"> <?php echo $score; ?> </h1>
|
||||
<h1 style="text-align: center;">150pts</h1>
|
||||
<div class="character">
|
||||
<img src="assets/Design/KnightPixLE.png" alt="knight">
|
||||
</div>
|
||||
@ -58,26 +46,25 @@ if($result){
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<?php
|
||||
<!-- <?php
|
||||
$peringkat = 1;
|
||||
if (!empty($leaderboard)) {
|
||||
foreach ($leaderboard as $pemain) :
|
||||
?>
|
||||
<tr>
|
||||
<td><?php echo $peringkat; ?></td>
|
||||
<td><?php echo htmlspecialchars($pemain['username']); ?></td>
|
||||
|
||||
<td><?php echo $pemain['score']; ?> PTS</td>
|
||||
</tr>
|
||||
?>
|
||||
|
||||
<tr>
|
||||
<td><?php echo $peringkat; ?></td>
|
||||
<td><?php echo htmlspecialchars($pemain['username']); ?></td>
|
||||
<td><?php echo $pemain['poin']; ?> PTS</td>
|
||||
</tr>
|
||||
|
||||
<?php
|
||||
$peringkat++;
|
||||
<?php
|
||||
$peringkat++;
|
||||
endforeach;
|
||||
} else {
|
||||
// Jika data kosong
|
||||
echo '<tr><td colspan="3" style="text-align: center;">Belum ada pemain</td></tr>';
|
||||
}
|
||||
?>
|
||||
|
||||
if (empty($leaderboard)) {
|
||||
echo '<tr><td colspan="3" style="text-align: center;">Belum ada pemain</td></tr>';
|
||||
}
|
||||
?> -->
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
|
||||
@ -32,7 +32,7 @@ if(isset($_POST['register'])){
|
||||
|
||||
$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->bind_param("is", $new_user_id, $username);
|
||||
|
||||
@ -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 */;
|
||||
Loading…
x
Reference in New Issue
Block a user