first commit
This commit is contained in:
42
search_73.php
Normal file
42
search_73.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
require_once "db_config.php"; // 引入数据库配置
|
||||
$conn = $link;
|
||||
// 判断是否有表单提交过来的数据
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
$search_name = $_POST['search_name'];
|
||||
// 编写SQL查询语句,从user_70表中根据姓名查找对应的地址信息
|
||||
$sql = "SELECT address FROM user_70 WHERE name = '$search_name'";
|
||||
$result = $conn->query($sql);
|
||||
if ($result->num_rows > 0) {
|
||||
// 如果查询到数据,输出对应的地址
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo $row["address"];
|
||||
}
|
||||
} else {
|
||||
// 如果没有查询到数据,输出提示信息
|
||||
echo "查无此人";
|
||||
}
|
||||
}
|
||||
|
||||
// 关闭数据库连接
|
||||
$conn->close();
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>姓名查询</title>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<!-- 创建form表单,用于输入姓名进行查询 -->
|
||||
<form action="search_73.php" method="post">
|
||||
<label for="sName">姓名:</label>
|
||||
<input type="text" id="sName" name="sName">
|
||||
<input type="submit" id="ok" name="ok" value="确定">
|
||||
</form>
|
||||
</body>
|
||||
|
||||
</html>
|
Reference in New Issue
Block a user