-
Notifications
You must be signed in to change notification settings - Fork 0
/
recommend_backend.php
85 lines (72 loc) · 1.97 KB
/
recommend_backend.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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>图书在馆状态</title>
<style>
* {
margin: 0;
padding: 0;
}
html,
body {
height: 100%;
background-color: rgb(173, 169, 129);
}
.head {
text-align: center;
font-family: Microsoft Yahei;
font-size: 90px;
font-weight: bold;
color: white;
height: 40%;
}
table {
text-align: center;
margin: 0px auto;
border: 5px double;
width: 35%;
}
a {
color: white;
font-size: 20px;
}
.bottom {
text-align: center;
}
</style>
</head>
<body>
<?php
$type = $_POST['type']; // 搜索类型传入本页面
$mysqli = mysqli_connect("localhost", "root", "", "library");
if (mysqli_connect_errno()) {
die("Failed to connect to MySQL: (" . mysqli_connect_errno() . ") " . mysqli_connect_error());
}
// echo 'sucessful to connect to MySQL!<br/>';
// 输出表格
echo "<table border='4px' cellpadding='15px' cellspacing='0px'>";
if ($type == 'hot') {
$str = "select bookName,category,frequency from book order by frequency DESC limit 10"; //排名前十的图书
echo "<div class='head'><br>热书书单</div>";
echo "<tr><td>图书名</td><td>图书类别</td><td>频度</td></tr>";
}
if ($type == 'latest') {
$str = "select bookName,category,importDate from book order by importDate DESC limit 10";
echo "<div class='head'><br>新书书单</div>";
echo "<tr><td>图书名</td><td>图书类别</td><td>上架时间</td></tr>";
}
if ($res = mysqli_query($mysqli, $str)) {
while ($row = mysqli_fetch_row($res)) {
echo "<tr><td>$row[0]</td><td>$row[1]</td><td>$row[2]</td></tr>";
}
}
echo "</table>";
// 表格输出完毕
echo "<div class='bottom'><br><a href='recommend.php' >返回上一页面</a></br>";
echo "<a href='main.php' ><br>回到首页</a></br></div>";
mysqli_close($mysqli); //还差美化界面 -> TODO: 等测试阶段进行
?>
</body>
</html>