-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsearch.php
More file actions
54 lines (54 loc) · 1.73 KB
/
Copy pathsearch.php
File metadata and controls
54 lines (54 loc) · 1.73 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
<?php
if ($_POST["id"] == "" && $_POST["name"] == "" && $_POST["sex"] == "" && $_POST["class"] == "") {
echo "请至少填写一个!";
header("Refresh:2;url=../index.php");
} else {
$db_host = "localhost";
$db_username = "root";
$db_password = "root";
$db_name = "tang";
$table_name = "user";
$conn = mysqli_connect($db_host, $db_username, $db_password);
mysqli_select_db($conn, $db_name);
$sql = "SELECT * from `" . $table_name . "` WHERE 1";
if ($_POST["id"] != "") {
$sql .= " and `id`=" . $_POST["id"];
}
if ($_POST["name"] != "") {
$sql .= " and `name`=\"" . $_POST["name"] . "\"";
}
if ($_POST["sex"] != "") {
$sql .= " and `sex`=\"" . $_POST["sex"] . "\"";
}
if ($_POST["class"] != "") {
$sql .= " and `class`=\"" . $_POST["class"] . "\"";
}
$sql .= ";";
// echo $sql . "<br>";
$result = mysqli_query($conn, $sql);
if (!$result) {
die("ERROR:" . mysqli_error($conn));
}
echo "<table border=1>";
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>";
}
echo "</table>";
}