forked from arcxingye/EatKano
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrank.php
98 lines (96 loc) · 3.9 KB
/
rank.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
<!DOCTYPE html>
<html>
<head>
<title>吃掉小鹿乃-排行榜</title>
<meta item="description" content="来看神仙" />
<meta itemprop="image" content="https://www.thac.cc/kano/res/logo.jpg" />
<meta charset="utf-8" />
<meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
</head>
<body>
<?php
include('conn.php');
$lbtype = isset($_GET['lbtype']) ? $_GET['lbtype'] : 'day';
$num = 30;
$page = isset($_GET['page']) ? $_GET['page'] : 1;
if ($page <= 0) {
$page = $page + 1;
}
$offset = ($page - 1) * $num;
if ($lbtype == 'day') {
$title = "日";
$cond = "to_days(time) = to_days(now())";
}
if ($lbtype == 'week') {
$title = "周";
$cond = "DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(time)";
}
if ($lbtype == 'month') {
$title = "月";
$cond = "DATE_SUB(CURDATE(), INTERVAL 30 DAY) <= date(time)";
}
$filtercond = " ORDER BY score DESC limit {$offset},{$num};";
$sql1="SELECT * FROM ".$ranking." where ".$cond.$filtercond;
$sql2="SELECT count(*) FROM ".$ranking." where ".$cond;
?>
<nav aria-label="breadcrumb">
<ol class="breadcrumb">
<li class="breadcrumb-item"><a href="./index.php">返回</a></li>
<li class="breadcrumb-item"><a href="https://www.thac.cc">官网</a></li>
<li class="breadcrumb-item"><a href="?lbtype=day">日榜</a></li>
<li class="breadcrumb-item"><a href="?lbtype=week">周榜</a></li>
<li class="breadcrumb-item"><a href="?lbtype=month">月榜</a></li>
<li class="breadcrumb-item"><a href="https://www.thac.cc/kano/index.html">大鹿乃</a></li>
</ol>
</nav>
<div class="page-header text-center">
<h1>排行榜(<?php echo $title; ?>榜)</h1>
<!-- 顶部广告区 -->
<!--THAC游戏服群(有MC/TR等)<a href="https://qm.qq.com/cgi-bin/qm/qr?k=qF_FKkfuJGsvXotE8nWLJhpjxYB19_o1&jump_from=webapi">180093493</a><br/>-->
<a href="./description.html">查看说明-<<</a> <a href="https://space.bilibili.com/3853579">查看作者-<<<</a>
</div>
<div class="list-group">
<?php
//数据
$result1 = mysqli_query($link, $sql1);
$data = mysqli_fetch_all($result1);
//数据的长度
$result2 = mysqli_query($link, $sql2);
$count = mysqli_fetch_row($result2);
//想要多少页就把9改成多少
if ($count[0] > $num * 9) {
$count = $num * 9;
} else {
$count = $count[0];
}
$total = ceil($count / $num);
if ($page >= $total) {
$page = $page - 1;
}
$rank = $offset;
foreach ($data as $row) :
$rank += 1;
echo "<a href='#' class='list-group-item list-group-item-action'><div class='d-flex w-100 justify-content-between'>
<h5 class='mb-1'>" . $rank . "位 " . $row[2] . "</h5><small>" . $row[3] . "</small></div><p class='mb-1'>SCORE: " . $row[1] . " -" . $row[4] . " -" . $row[5] . "</p>
<small>" . $row[6] . "</small></a>";
endforeach
?>
<nav aria-label="Page navigation example">
<ul class="pagination">
<?php
$total = ceil($count / $num);
if ($page >= $total) {
$page = $page - 1;
}
echo "<li class='page-item'>";
echo "<a class='page-link' href='?lbtype=" . $lbtype . "&page=" . ($page - 1) . "' aria-label='Previous'><span aria-hidden='true'>«</span></a></li>";
for ($p = 1; $p <= $total; $p++) {
echo "<li class='page-item'><a class='page-link' href='?lbtype=" . $lbtype . "&page=" . $p . "'>" . $p . "</a></li>";
}
echo "<li class='page-item'><a class='page-link' href='?lbtype=" . $lbtype . "&page=" . ($page + 1) . "' aria-label='Next'><span aria-hidden='true'>»</span></a></li>";
?>
</ul>
</nav>
</div>
</body>