add files
This commit is contained in:
27
api_73_5_e_insert.php
Normal file
27
api_73_5_e_insert.php
Normal file
@ -0,0 +1,27 @@
|
||||
<?php
|
||||
// 数据库连接
|
||||
include 'db_config.php';
|
||||
|
||||
// 获取请求参数
|
||||
$id = $_GET['id'];
|
||||
$name = $_GET['name'];
|
||||
$address = $_GET['address'];
|
||||
$event_time = intval($_GET['event_time']);
|
||||
$code = $_GET['code'];
|
||||
|
||||
// 检查是否已有相同记录
|
||||
$sql_check = "SELECT * FROM nucleic_acid_test_2 WHERE id = '$id' AND address = '$address' AND event_time = $event_time";
|
||||
$result_check = $link->query($sql_check);
|
||||
|
||||
if ($result_check->num_rows > 0) {
|
||||
// 如果已有记录,直接返回码值
|
||||
echo $code;
|
||||
} else {
|
||||
// 插入新记录
|
||||
$sql_insert = "INSERT INTO nucleic_acid_test_2 (id, name, address, event_time, code) VALUES ('$id', '$name', '$address', $event_time, '$code')";
|
||||
if ($link->query($sql_insert) === TRUE) {
|
||||
echo $code;
|
||||
} else {
|
||||
echo "插入失败: " . $link->error;
|
||||
}
|
||||
}
|
50
api_73_5_e_select.php
Normal file
50
api_73_5_e_select.php
Normal file
@ -0,0 +1,50 @@
|
||||
<?php
|
||||
// 数据库连接
|
||||
include "db_config.php";
|
||||
$conn = $link;
|
||||
|
||||
// 获取请求参数
|
||||
$id = $_GET['id'];
|
||||
$name = $_GET['name'];
|
||||
$address = $_GET['address'];
|
||||
$event_time = intval($_GET['event_time']);
|
||||
|
||||
// 查询是否存在红码时空交集
|
||||
$sql_red = "SELECT * FROM nucleic_acid_test_2
|
||||
WHERE address = '$address' AND ABS(event_time - $event_time) < 1800 AND code = '3'";
|
||||
$result_red = $conn->query($sql_red);
|
||||
|
||||
if ($result_red->num_rows > 0) {
|
||||
// 存在红码时空交集,赋红码并入库
|
||||
$sql_check = "SELECT * FROM nucleic_acid_test_2 WHERE id = '$id' AND address = '$address' AND event_time = $event_time";
|
||||
$result_check = $conn->query($sql_check);
|
||||
if ($result_check->num_rows == 0) {
|
||||
$sql_insert = "INSERT INTO nucleic_acid_test_2 (id, name, address, event_time, code) VALUES ('$id', '$name', '$address', $event_time, '3')";
|
||||
$conn->query($sql_insert);
|
||||
}
|
||||
echo "3";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// 查询是否存在黄码时空交集
|
||||
$sql_yellow = "SELECT * FROM nucleic_acid_test_2
|
||||
WHERE (address = '$address' OR ABS(event_time - $event_time) < 1800) AND code = '2'";
|
||||
$result_yellow = $conn->query($sql_yellow);
|
||||
|
||||
if ($result_yellow->num_rows > 0) {
|
||||
// 存在黄码时空交集,赋黄码并入库
|
||||
$sql_check = "SELECT * FROM nucleic_acid_test_2 WHERE id = '$id' AND address = '$address' AND event_time = $event_time";
|
||||
$result_check = $conn->query($sql_check);
|
||||
if ($result_check->num_rows == 0) {
|
||||
$sql_insert = "INSERT INTO nucleic_acid_test_2 (id, name, address, event_time, code) VALUES ('$id', '$name', '$address', $event_time, '2')";
|
||||
$conn->query($sql_insert);
|
||||
}
|
||||
echo "2";
|
||||
$conn->close();
|
||||
exit;
|
||||
}
|
||||
|
||||
// 无风险,返回绿码
|
||||
echo "1";
|
||||
?>
|
28
drop_tables.php
Normal file
28
drop_tables.php
Normal file
@ -0,0 +1,28 @@
|
||||
<?php
|
||||
include_once("db_config.php");
|
||||
$conn = $link;
|
||||
$sql = "DROP TABLE IF EXISTS `user_70`;";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if ($result) {
|
||||
echo "Table users dropped successfully.";
|
||||
} else {
|
||||
echo "Error dropping table: " . mysqli_error($conn);
|
||||
}
|
||||
|
||||
$sql = "DROP TABLE IF EXISTS `nucleic_acid_test_2`;";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if ($result) {
|
||||
echo "Table users dropped successfully.";
|
||||
} else {
|
||||
echo "Error dropping table: " . mysqli_error($conn);
|
||||
}
|
||||
|
||||
$sql = "DROP TABLE IF EXISTS `patient_90`;";
|
||||
$result = mysqli_query($conn, $sql);
|
||||
if ($result) {
|
||||
echo "Table users dropped successfully.";
|
||||
} else {
|
||||
echo "Error dropping table: " . mysqli_error($conn);
|
||||
}
|
||||
mysqli_close($conn);
|
||||
|
3
exam_config.php
Normal file
3
exam_config.php
Normal file
@ -0,0 +1,3 @@
|
||||
<?php
|
||||
$link=mysqli_connect('localhost','user_20241115_58056','K6UJKaRLiipvw','exam_20241115_58056');
|
||||
mysqli_query($link,'set names utf8');
|
15
exam_setup.php
Normal file
15
exam_setup.php
Normal file
@ -0,0 +1,15 @@
|
||||
<?php
|
||||
require_once "exam_config.php";
|
||||
|
||||
//先删除在创建
|
||||
mysqli_query($link,"drop table user_70");
|
||||
|
||||
$queryString="create table user_70(name char(50),address char(50),password char(50))ENGINE=MyISAM DEFAULT CHARSET=utf8";
|
||||
mysqli_query($link,$queryString);
|
||||
echo mysqli_error($link)."<br>";
|
||||
$queryString="insert into user_70(name,address,password)values('mike','shanghai','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$queryString);
|
||||
echo mysqli_error($link)."<br>";
|
||||
$queryString="insert into user_70(name,address,password)values('rose','beijing','c4ca4238a0b923820dcc509a6f75849b')";
|
||||
mysqli_query($link,$queryString);
|
||||
echo mysqli_error($link)."<br>";
|
27
form_test_1.php
Normal file
27
form_test_1.php
Normal file
@ -0,0 +1,27 @@
|
||||
<meta charset="UTF-8">
|
||||
<?php
|
||||
//里程碑 拿到浏览器提交的数据,数据重现(现场恢复) 无状态协议模式 stateless
|
||||
//实现单选,复选,下拉框的数据重现
|
||||
if(isset($_POST['ok'])){
|
||||
//单选按钮与复选框在用户没有操作的情况下不会提交默认值到服务器,因此需要单独做逻辑处理
|
||||
//var_dump($_POST);
|
||||
echo $_POST['name'];
|
||||
echo $_POST['age'];
|
||||
$name=$_POST['name'];
|
||||
$age=$_POST['age'];
|
||||
|
||||
}else{
|
||||
$name="姓名不能为空";
|
||||
$age = "";
|
||||
}
|
||||
|
||||
?>
|
||||
<form action="" method="post">
|
||||
姓名:<input type="text" id="name" name="name" value="<?php echo $name;?>"><br>
|
||||
年龄:<input type="text" id="age" name="age" value="<?php echo $age;?>"><br></br>
|
||||
<br>
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
<script>
|
||||
|
||||
</script>
|
20
img_code_1.php
Normal file
20
img_code_1.php
Normal file
@ -0,0 +1,20 @@
|
||||
<?php
|
||||
//GD
|
||||
//phpinfo();
|
||||
//登录验证码
|
||||
session_start();
|
||||
|
||||
header("Content-type: image/png; charset=utf-8");
|
||||
//创建一个图片
|
||||
$image = imagecreate(120,30);
|
||||
//定义背景颜色
|
||||
$black = imagecolorallocate($image,255, 0, 0);//reb 000代表黑
|
||||
//定义前景颜色
|
||||
$white = imagecolorallocate($image,255, 255, 255);
|
||||
|
||||
imagefill($image, 0, 0, $black );//向图片中填充背景
|
||||
$string = $_GET['img_code'];
|
||||
//把文字写到图片中
|
||||
imagestring( $image, 5, 6, 4, $string, $white);
|
||||
//生成png格式图形
|
||||
imagepng( $image );
|
80
list_72_1.php
Normal file
80
list_72_1.php
Normal file
@ -0,0 +1,80 @@
|
||||
<meta charset="UTF-8">
|
||||
<?php
|
||||
//数据列表 带编辑,新增与删除操作
|
||||
//引入数据库配置文件
|
||||
/*
|
||||
* select * from student_1 limit 0,10
|
||||
* select * from student_1 limit 10,10
|
||||
*
|
||||
*/
|
||||
require_once "db_config.php";
|
||||
mysqli_set_charset($link, 'utf8');
|
||||
//取总记录数
|
||||
$queryString="select count(name) as maxRows from user_70";
|
||||
$rs=mysqli_query($link,$queryString);
|
||||
$row=mysqli_fetch_assoc($rs);
|
||||
$maxRows=$row['maxRows'];
|
||||
|
||||
$rowsOfPage = $_GET['rows_of_page'] ?? 10;
|
||||
|
||||
|
||||
|
||||
if(isset($_GET['action'])){
|
||||
//翻页进入
|
||||
if($_GET['action']=="top"){
|
||||
$offset=0;
|
||||
}
|
||||
|
||||
if($_GET['action']=="previous"){
|
||||
$offset=$_GET['offset']-$rowsOfPage;
|
||||
if($offset<0){
|
||||
$offset=0;
|
||||
}
|
||||
}
|
||||
if($_GET['action']=="next"){
|
||||
$offset=$_GET['offset']+$rowsOfPage;
|
||||
//处理最后一页的计算逻辑
|
||||
if($offset>=$maxRows){
|
||||
$offset=$_GET['offset'];
|
||||
}
|
||||
}
|
||||
if($_GET['action']=='bottom'){
|
||||
if($maxRows%$rowsOfPage==0){
|
||||
//整页
|
||||
$offset=$maxRows-$rowsOfPage;
|
||||
}else{
|
||||
//非整页
|
||||
$offset=$maxRows-$maxRows%$rowsOfPage;
|
||||
//20 10 20-10 25-25%10 20
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}else{
|
||||
//第一次进入,偏移量为0
|
||||
$offset=0;
|
||||
}
|
||||
$queryString="select * from user_70 limit $offset,$rowsOfPage";
|
||||
$rs=mysqli_query($link,$queryString);
|
||||
//用循环语句,从数据集中读出每一条记录
|
||||
echo "<table border='1'>";
|
||||
//id,name,password,gender,birthday,course,hometown,resume
|
||||
echo "<tr><td colspan='10'>姓名列表</td>";
|
||||
$pattern = '/(\d+)/';
|
||||
while ($row=mysqli_fetch_assoc($rs)){
|
||||
preg_match_all($pattern, $row['name'], $matches);
|
||||
echo "<tr>";
|
||||
echo "<td>".($matches[0][0]+1)."</td>";
|
||||
echo "<td>".$row['name']."</td>";
|
||||
|
||||
}
|
||||
echo "<tr><td colspan='10'>
|
||||
<a href='list_72_1.php?action=top&offset=$offset&rows_of_page=$rowsOfPage'>首页</a>
|
||||
|
|
||||
<a href='list_72_1.php?action=previous&offset=$offset&rows_of_page=$rowsOfPage'>上一页</a>
|
||||
|
|
||||
<a href='list_72_1.php?action=next&offset=$offset&rows_of_page=$rowsOfPage'>下一页</a>
|
||||
|
|
||||
<a href='list_72_1.php?action=bottom&offset=$offset&rows_of_page=$rowsOfPage'>末页</a>
|
||||
</td></tr>";
|
||||
echo "</table>";
|
4
my_first_program.php
Normal file
4
my_first_program.php
Normal file
@ -0,0 +1,4 @@
|
||||
<?php
|
||||
$link=mysqli_connect("localhost",'user_20241115_58056','K6UJKaRLiipvw','exam_20241115_58056');
|
||||
mysqli_query($link,"set names utf8");
|
||||
var_dump($link);
|
72
patient_90.php
Normal file
72
patient_90.php
Normal file
@ -0,0 +1,72 @@
|
||||
<?php
|
||||
require 'db_config.php';
|
||||
$conn = $link;
|
||||
mysqli_set_charset($link, 'utf8');
|
||||
// 初始化变量
|
||||
$patient_id = $patient_name = $patient_gender = $patient_address = "";
|
||||
|
||||
// 检查表单提交
|
||||
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
|
||||
$patient_id = ($_POST['patient_id']);
|
||||
$patient_name = ($_POST['patient_name']);
|
||||
$patient_gender = ($_POST['patient_gender']);
|
||||
$patient_address = ($_POST['patient_address']);
|
||||
|
||||
// 保存数据
|
||||
try {
|
||||
// 检查是否存在该患者
|
||||
$query = "SELECT COUNT(*) AS count FROM patient_90 WHERE patient_id = '$patient_id'";
|
||||
$result = mysqli_query($conn, $query);
|
||||
$row = mysqli_fetch_assoc($result);
|
||||
|
||||
if ($row['count'] > 0) {
|
||||
// 更新记录
|
||||
$update_query = "UPDATE patient_90 SET
|
||||
patient_name = '$patient_name',
|
||||
patient_gender = '$patient_gender',
|
||||
patient_address = '$patient_address'
|
||||
WHERE patient_id = '$patient_id'";
|
||||
mysqli_query($conn, $update_query);
|
||||
} else {
|
||||
// 插入新记录
|
||||
$insert_query = "INSERT INTO patient_90
|
||||
(patient_id, patient_name, patient_gender, patient_address)
|
||||
VALUES
|
||||
('$patient_id', '$patient_name', '$patient_gender', '$patient_address')";
|
||||
mysqli_query($conn, $insert_query);
|
||||
}
|
||||
} catch (Exception $e) {
|
||||
die("数据保存失败: " . $e->getMessage());
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>患者建档</title>
|
||||
</head>
|
||||
<body>
|
||||
<h1>患者建档</h1>
|
||||
<form action="patient_90.php" method="post">
|
||||
<label for="patient_name">姓名:</label>
|
||||
<input type="text" id="patient_name" name="patient_name" value=""><br>
|
||||
|
||||
<label for="patient_id">身份证:</label>
|
||||
<input type="text" id="patient_id" name="patient_id" value=""><br>
|
||||
|
||||
<label>性别:</label>
|
||||
<input type="radio" id="male" name="patient_gender" value="1" <?= $patient_gender === '1' ? 'checked' : '' ?>>
|
||||
<label for="male">男</label>
|
||||
<input type="radio" id="female" name="patient_gender" value="2" <?= $patient_gender === '2' ? 'checked' : '' ?>>
|
||||
<label for="female">女</label><br>
|
||||
|
||||
<label for="patient_address">家庭住址:</label>
|
||||
<input type="text" id="patient_address" name="patient_address" value=""><br>
|
||||
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
29
program_85.php
Normal file
29
program_85.php
Normal file
@ -0,0 +1,29 @@
|
||||
<?php
|
||||
// 自定义函数实现首尾字母交换
|
||||
function mySwap($string) {
|
||||
// 检查字符串是否为空或长度为1
|
||||
if (strlen($string) <= 1) {
|
||||
return $string;
|
||||
}
|
||||
|
||||
// 获取首字母和尾字母
|
||||
$firstChar = $string[0];
|
||||
$lastChar = $string[strlen($string) - 1];
|
||||
|
||||
// 替换首尾字母
|
||||
$swappedString = $lastChar . substr($string, 1, -1) . $firstChar;
|
||||
|
||||
return $swappedString;
|
||||
}
|
||||
|
||||
// 获取URL传递的字符串
|
||||
if (isset($_GET['string'])) {
|
||||
$string = $_GET['string'];
|
||||
|
||||
// 输出结果
|
||||
echo mySwap($string);
|
||||
} else {
|
||||
echo "请通过URL传递字符串,例如:program_85.php?string=example";
|
||||
}
|
||||
?>
|
||||
<?php
|
5
robot_251.php
Normal file
5
robot_251.php
Normal file
@ -0,0 +1,5 @@
|
||||
<?php
|
||||
$content = file_get_contents("http://125.64.9.222:8022/goods/flash_sale.php");
|
||||
$pattern = '/\d+(?=元)/';
|
||||
preg_match_all($pattern, $content, $matches);
|
||||
echo "[".$matches[0][1]."]";
|
74
search_73_1.php
Normal file
74
search_73_1.php
Normal file
@ -0,0 +1,74 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="zh-CN">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>姓名与地址查询</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
<form method="POST" action="search_73_1.php">
|
||||
<label for="searchName">姓名查询:</label>
|
||||
<input type="text" id="searchName" name="searchName">
|
||||
|
||||
<label for="searchAddress">地址查询:</label>
|
||||
<input type="text" id="searchAddress" name="searchAddress">
|
||||
|
||||
<label for="and">AND</label>
|
||||
<input type="radio" id="and" name="searchLogic" value="and" checked>
|
||||
|
||||
<label for="or">OR</label>
|
||||
<input type="radio" id="or" name="searchLogic" value="or">
|
||||
|
||||
<input type="submit" id="ok" name="ok" value="ok">
|
||||
</form>
|
||||
|
||||
<?php
|
||||
include_once 'db_config.php';
|
||||
if ($_SERVER["REQUEST_METHOD"] == "POST") {
|
||||
// 获取用户输入的查询条件
|
||||
$searchName = $_POST['searchName'] ?? '';
|
||||
$searchAddress = $_POST['searchAddress'] ?? '';
|
||||
$searchLogic = $_POST['searchLogic'] ?? 'and';
|
||||
|
||||
// 设置字符集
|
||||
mysqli_set_charset($link, "utf8");
|
||||
// 动态构建查询语句
|
||||
$conditions = [];
|
||||
$params = [];
|
||||
$types = '';
|
||||
|
||||
if (!empty($searchName)) {
|
||||
$conditions[] = "name = ?";
|
||||
$params[] = $searchName;
|
||||
$types .= 's';
|
||||
}
|
||||
|
||||
if (!empty($searchAddress)) {
|
||||
$conditions[] = "address = ?";
|
||||
$params[] = $searchAddress;
|
||||
$types .= 's';
|
||||
}
|
||||
|
||||
if (count($conditions) > 0) {
|
||||
$sql = "SELECT * FROM user_70 WHERE " . implode(" " . strtoupper($searchLogic) . " ", $conditions);
|
||||
$stmt = $link->prepare($sql);
|
||||
$stmt->bind_param($types, ...$params);
|
||||
$stmt->execute();
|
||||
$result = $stmt->get_result();
|
||||
|
||||
$rowCount = $result->num_rows;
|
||||
echo "<p>[" . $rowCount . "]</p>"; // 显示记录数
|
||||
|
||||
if ($rowCount > 0) {
|
||||
while ($row = $result->fetch_assoc()) {
|
||||
echo "<p>姓名: " . htmlspecialchars($row['name']) . " 地址: " . htmlspecialchars($row['address']) . "</p>";
|
||||
}
|
||||
}
|
||||
|
||||
$stmt->close();
|
||||
} else {
|
||||
// 如果没有提供查询条件则不执行查询
|
||||
echo "<p>[0]</p>";
|
||||
}
|
||||
}
|
||||
?>
|
1
upload/test_upload.txt
Normal file
1
upload/test_upload.txt
Normal file
@ -0,0 +1 @@
|
||||
6rlWseYg4VDRzwkAjLo
|
14
www/admin/back_index.php
Normal file
14
www/admin/back_index.php
Normal file
@ -0,0 +1,14 @@
|
||||
|
||||
<?php
|
||||
?>
|
||||
<!DOCTYPE html>
|
||||
<html lang="Zh-CN">
|
||||
<head>
|
||||
<title>main</title>
|
||||
</head>
|
||||
<body>
|
||||
<iframe src="top.html"></iframe>
|
||||
<iframe src="left.html"></iframe>
|
||||
<iframe src="right.html"></iframe>
|
||||
</body>
|
||||
</html>
|
10
www/admin/left.html
Normal file
10
www/admin/left.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
10
www/admin/right.html
Normal file
10
www/admin/right.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
10
www/admin/top.html
Normal file
10
www/admin/top.html
Normal file
@ -0,0 +1,10 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<title>Title</title>
|
||||
</head>
|
||||
<body>
|
||||
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user