-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathleaderboard.php
41 lines (39 loc) · 966 Bytes
/
leaderboard.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
include 'conn.php';
if ($_COOKIE['user']=='admin') {
echo '<nav>
<a href="solve.php">Questions</a>
<a href="leaderboard.php">Leaderboard</a>
<a href="add.php">Add Questions</a>
<a href="viewques.php">View all available questions</a>
<a href="logout.php" style="float: right;">Logout</a>
</nav>';
}else{
echo '<nav>
<a href="solve.php">Questions</a>
<a href="leaderboard.php">Leaderboard</a>
<a href="logout.php" style="float: right;">Logout</a>
</nav>';
}
echo "<h1>Leaderboard</h1>";
$i=1;
$query='SELECT * FROM Users ORDER BY points DESC';
$result=$conn->query($query);
echo "<table>";
echo "<tr>";
echo "<th>Rank</th>";
echo "<th>Name</th>";
echo "<th>Points</th>";
echo "</tr>";
while ($row=mysqli_fetch_assoc($result)) {
if ($row['username']!='admin') {
echo "<tr>";
echo "<td>".$i."</td>";
echo "<td>".$row['username']."</td>";
echo "<td>".$row['points']."</td>";
echo "</tr>";
$i++;
}
}
echo "</table>"
?>