-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathleader.php
134 lines (112 loc) · 3.15 KB
/
leader.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
<!doctype html>
<html>
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Leaderboard</title>
<link rel="icon" href="../images/icon.png" type="image/png" sizes="16x16">
<link rel="stylesheet" href="css/style.css" type="text/css">
<link rel="stylesheet" type="text/css" href="css/mobile.css">
<script src="js/mobile.js" type="text/javascript"></script>
</head>
<body>
<div id="page">
<div id="header">
<div id="navigation">
<span id="mobile-navigation"> </span>
<a href="index.php" class="logo"><img src="images/logo.png" alt=""></a>
<ul id="menu">
<li class="selected">
<a href="index.php">Home</a>
</li>
<li>
<a href="leader.php">Leader Board</a>
</li>
<li>
<a href="rules.php">RuLES</a>
</li>
<li>
<a href="https://www.facebook.com/decipher.ritu" target="_blank">WATSON</a>
</li>
<?php
session_start();
if (isset($_SESSION["fbuid"]))
echo "<li>
<a href=\"logout.php\">logout</a>
</li>";
?>
</ul>
</div>
</div>
<div id="body">
<div class="container tablestyle">
<h1 id="rank" align="center" > brains</h1>
<h4>
<table width="100%" >
<tr align="justify" height="40"><th width="10%">RANK</th><th width="25%">NAME</th><th width="16%">COLLEGE</th><th width="10%">LEVEL</th></tr>
<!-- start here-->
<?php
session_start();
require_once("database.php");
global $result;
$sql = "SELECT name,level,college FROM users WHERE role!=-1 ORDER BY level DESC";
$ref = $result->query($sql);
$count=mysqli_num_rows($ref);
$per=20;
$pagecount=ceil($count/$per);
$page=$_GET["page"];
if ($page=="")
{
$page=1;
}
if ($page==1)
{
$offset=0;
}
else {
$offset=($page-1)*$per;
}
$sql = "SELECT name,level,college FROM users WHERE role not in(-1,10) ORDER BY level DESC, passtime ASC LIMIT $offset,$per";
$ref = $result->query($sql);
$rank=$offset+1;
while($row = mysqli_fetch_assoc($ref))
{ if($page==1){
echo "<tr class=\"row\" id=\"rank".$rank."\"><td>".$rank."</td><td>".$row["name"]."</td><td>".$row["college"]."</td><td>".$row["level"]."</td></tr>";
$rank++;
}
else{
echo "<tr class=\"row\"><td>".$rank."</td><td>".$row["name"]."</td><td>".$row["college"]."</td><td>".$row["level"]."</td></tr>";
$rank++;
}
}
?></table>
<div id="paging">
<?php
if($page>1)
{
?><a class="link" href="leader.php?page=<?php echo $page-1?>"><?php echo "previous " ?></a> <?php
}
$adjacents=2;
$start = ($page < $adjacents ? 1 : $page - $adjacents);
$end = ($page > $pagecount - $adjacents ? $pagecount : $page + $adjacents);
if($start==0)
{
$start=1;
}
for ($i=$start;$i<=$end;$i++)
{
?><a class="link" href="leader.php?page=<?php echo $i?>"><?php echo $i." " ?></a> <?php
}
if($pagecount>$page)
{
?><a class="link" href="leader.php?page=<?php echo $page+1?>"><?php echo "Next " ?></a> <?php
}
?>
</div>
<!-- end here-->
</h4>
</div>
</div>
</div>
</body>
</html>