-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpRanking.php
95 lines (84 loc) · 2.81 KB
/
pRanking.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
<!-- page content -->
<div class="right_col" role="main">
<?php
include "pOwns.php";
?>
<div class="dashboard_graph">
<div class="row x_title">
<div class="col-md-6">
<h3>Sıralama</h3>
</div>
</div>
<?php
echo "<b>Toplam Kullanıcı Sayısı:".$conn->query("SELECT count(id) AS total FROM users")->fetch_assoc()['total']."</b>\n";
?>
<div class="col-md-12 col-sm-12 col-xs-12">
<table class="table">
<thead>
<tr>
<th>#</th>
<th>Kullanıcı Adı</th>
<th>Puanı</th>
</tr>
</thead>
<tbody>
<?php
$perPage = 17;
$retVal = $conn->query("SELECT count(id) AS total FROM users")->fetch_assoc();
$pageCount = ceil($retVal["total"] / $perPage);
$page = 0; if(isset($_GET["p"])) $page = $_GET["p"];
if($page <= 0) $page = 1;
if($page >= $pageCount) $page = $pageCount;
$i = 0;
$search = $conn->query("SELECT * FROM users ORDER BY points DESC LIMIT ".($page - 1) * $perPage.", ".$perPage."");
while($row = $search->fetch_assoc()){
$i++;
?>
<tr>
<td><?php echo ($page - 1) * $perPage + $i; ?></td>
<td>
<?php
echo $row["username"];
if(($page - 1) * $perPage + $i <= 3)
echo " - " . FIRST_THREE_STATUE;
else if(($page - 1) * $perPage + $i <= 10)
echo " - " . FIRST_TEN_STATUE;
else if(($page - 1) * $perPage + $i <= 100)
echo " - " . FIRST_HUNDRED_STATUE;
else
echo " - " . OTHERS_STATUE;
?>
</td>
<td><?php echo $row["points"]; ?> Puan</td>
</tr>
<?php
}
?>
<tr>
<td colspan="3"><center>
<?php
$start = $page - 4;
$end = $page + 4;
if($start < 1)
$start = 1;
if($end > $pageCount)
$end = $pageCount;
for($i = $start ; $i <= $end ; $i++){
if($i == $page)
echo " <b><a href='index.php?tab=ranking&p=".($i)."'><font color='green'>".($i)."</font></a></b>";
else
echo " <b><a href='index.php?tab=ranking&p=".($i)."'>".($i)."</a></b>";
if($i != $end)
echo " - ";
}
?>
</center></td>
</tr>
</tbody>
</table>
</div>
<div class="clearfix"></div>
</div>
<div class="row"> </div>
</div>
<!-- /page content -->