-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
72 lines (69 loc) · 2.28 KB
/
Copy pathindex.php
File metadata and controls
72 lines (69 loc) · 2.28 KB
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
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>主页</title>
</head>
<body>
<form action="tools/add_ui.php" method="get">
<input type="submit" value="添加">
</form>
<form action="tools/search.php" method="post">
<input type="text" name="id" placeholder="请输入id">
<input type="text" name="name" placeholder="请输入姓名">
<input type="text" name="sex" placeholder="请输入性别">
<input type="text" name="class" placeholder="请输入班级">
<input type="submit">
</form>
<table border=1>
<tr>
<th>id</th>
<th>姓名</th>
<th>性别</th>
<th>班级</th>
</tr>
<?php
$db_host = "localhost";
$db_username = "root";
$db_password = "root";
$db_name = "tang";
$table_name = "user";
$conn = mysqli_connect($db_host, $db_username, $db_password);
if (!$conn) {
die("Error:" . mysqli_error($conn));
}
mysqli_select_db($conn, $db_name);
if (!$conn) {
die("Error to connect database:" . mysqli_connect_error());
}
$sql = "select * from " . $table_name;
$result = mysqli_query($conn, $sql);
if (!$result) {
die("ERROR:" . mysqli_error($conn));
}
while ($item = mysqli_fetch_assoc($result)) {
echo "<tr>";
echo "<td>";
echo $item["id"];
echo "</td>";
echo "<td>";
echo $item["name"];
echo "</td>";
echo "<td>";
echo $item["sex"];
echo "</td>";
echo "<td>";
echo $item["class"];
echo "</td>";
echo "<td>";
echo "<button> <a href=\"tools/delete.php?id=" . $item["id"] . "\">删除</a></button>";
echo "<button> <a href=\"tools/modify_ui.php?id=" . $item["id"] . "&&sex=" . $item["sex"] . "&&name=" . $item["name"] . "&&class=" . $item["class"] . "\">修改</a></button>";
echo "</td>";
echo "</tr>";
}
?>
</table>
</body>
</html>