From e09a3127c02ed77734a7ebe0456da0173439a719 Mon Sep 17 00:00:00 2001 From: sdfonehs16 <102944584+sdfonehs16@users.noreply.github.com> Date: Mon, 28 Oct 2024 17:23:12 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E6=BA=90=E4=BB=A3=E7=A0=81?= =?UTF-8?q?=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add code files --- add.html | 27 +++++++++++++++++++++++++++ add.php | 30 ++++++++++++++++++++++++++++++ connect.php | 18 ++++++++++++++++++ del.html | 18 ++++++++++++++++++ del.php | 32 ++++++++++++++++++++++++++++++++ edit.html | 23 +++++++++++++++++++++++ edit.php | 34 ++++++++++++++++++++++++++++++++++ index.html | 15 +++++++++++++++ query.html | 16 ++++++++++++++++ query.php | 41 +++++++++++++++++++++++++++++++++++++++++ query_update.html | 16 ++++++++++++++++ query_update.php | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 12 files changed, 317 insertions(+) create mode 100644 add.html create mode 100644 add.php create mode 100644 connect.php create mode 100644 del.html create mode 100644 del.php create mode 100644 edit.html create mode 100644 edit.php create mode 100644 index.html create mode 100644 query.html create mode 100644 query.php create mode 100644 query_update.html create mode 100644 query_update.php diff --git a/add.html b/add.html new file mode 100644 index 0000000..25884e1 --- /dev/null +++ b/add.html @@ -0,0 +1,27 @@ + + + + + 学生信息录入 + + +

学生信息录入

+ +
+ +

+ + +

+ + +

+ + +
+ + + diff --git a/add.php b/add.php new file mode 100644 index 0000000..75cadb5 --- /dev/null +++ b/add.php @@ -0,0 +1,30 @@ +query($sql) === TRUE) { + echo "学生信息添加成功"; + } else { + echo "添加学生信息时出现错误: " . $conn->error; + } +} + +// 关闭数据库连接 +$conn->close(); +?> diff --git a/connect.php b/connect.php new file mode 100644 index 0000000..5ecb9b1 --- /dev/null +++ b/connect.php @@ -0,0 +1,18 @@ +connect_error) { + die("连接数据库失败: " . $conn->connect_error); +} +else +{ +echo "数据库连接成功!"; +} +?> diff --git a/del.html b/del.html new file mode 100644 index 0000000..c83bfa7 --- /dev/null +++ b/del.html @@ -0,0 +1,18 @@ + + + + + 学生信息删除 + + +

学生信息删除

+ +
+ +

+ + +
+ + + diff --git a/del.php b/del.php new file mode 100644 index 0000000..0e6d3c3 --- /dev/null +++ b/del.php @@ -0,0 +1,32 @@ +connect_error) { + die("连接数据库失败: " . $conn->connect_error); +} + +if ($_SERVER["REQUEST_METHOD"] == "POST") { + // 从表单获取学生姓名 + $name = $_POST["name"]; + + // 构建删除SQL语句 + $sql = "DELETE FROM student_info WHERE name='$name'"; + + // 执行删除操作 + if ($conn->query($sql) === TRUE) { + echo "学生信息删除成功"; + } else { + echo "删除学生信息时出现错误: " . $conn->error; + } +} + +// 关闭数据库连接 +$conn->close(); +?> diff --git a/edit.html b/edit.html new file mode 100644 index 0000000..492961a --- /dev/null +++ b/edit.html @@ -0,0 +1,23 @@ + + + + + 编辑学生信息 + + + +

编辑学生信息

+ +
+ 姓名:
+ 年龄:
+ 性别:
+ +
+ + diff --git a/edit.php b/edit.php new file mode 100644 index 0000000..118b2c5 --- /dev/null +++ b/edit.php @@ -0,0 +1,34 @@ +connect_error) { + die("连接数据库失败: " . $conn->connect_error); +} + +if ($_SERVER["REQUEST_METHOD"] == "POST") { + // 从表单获取学生信息 + $name = $_POST["name"]; + $age = $_POST["age"]; + $gender = $_POST["gender"]; + + // 构建更新SQL语句 + $sql = "UPDATE student_info SET age=$age, gender='$gender' WHERE name='$name'"; + + // 执行更新操作 + if ($conn->query($sql) === TRUE) { + echo "学生信息修改成功"; + } else { + echo "修改学生信息时出现错误: " . $conn->error; + } +} + +// 关闭数据库连接 +$conn->close(); +?> diff --git a/index.html b/index.html new file mode 100644 index 0000000..5dce4ac --- /dev/null +++ b/index.html @@ -0,0 +1,15 @@ + + + + + 学生信息管理系统 + + +

欢迎来到学生信息管理系统

+ + + + + + + diff --git a/query.html b/query.html new file mode 100644 index 0000000..dc4a26d --- /dev/null +++ b/query.html @@ -0,0 +1,16 @@ + + + + +查询学生信息 + + +

查询学生信息

+
+输入要查询的学生姓名: + +
+ +
+ + diff --git a/query.php b/query.php new file mode 100644 index 0000000..86cc92c --- /dev/null +++ b/query.php @@ -0,0 +1,41 @@ +connect_error) { + die("连接数据库失败: " . $conn->connect_error); + } + + if ($_SERVER["REQUEST_METHOD"] == "POST") { + // 从表单获取学生姓名 + $name = $_POST["name"]; + + // 构建查询SQL语句 + $sql = "SELECT * FROM student_info WHERE name='$name'"; + + // 执行查询操作 + $result = $conn->query($sql); + + if ($result->num_rows > 0) { + // 输出查询结果和编辑按钮 + while ($row = $result->fetch_assoc()) { + echo "
"; + echo "ID: " . $row["id"] . "
"; + echo "姓名: " . $row["name"] . "
"; + echo "年龄: " . $row["age"] . "
"; + echo "性别: " . $row["gender"] . "
"; + } + } else { + echo "
没有找到相关学生信息"; + } + } + + // 关闭数据库连接 + $conn->close(); + ?> \ No newline at end of file diff --git a/query_update.html b/query_update.html new file mode 100644 index 0000000..65f75ce --- /dev/null +++ b/query_update.html @@ -0,0 +1,16 @@ + + + + +修改学生信息 + + +

查询你所要修改的学生信息

+
+输入要修改的学生姓名: + +
+ +
+ + diff --git a/query_update.php b/query_update.php new file mode 100644 index 0000000..32d2ce7 --- /dev/null +++ b/query_update.php @@ -0,0 +1,47 @@ +connect_error) { + die("连接数据库失败: " . $conn->connect_error); + } + + if ($_SERVER["REQUEST_METHOD"] == "POST") { + // 从表单获取学生姓名 + $name = $_POST["name"]; + + // 构建查询SQL语句 + $sql = "SELECT * FROM student_info WHERE name='$name'"; + + // 执行查询操作 + $result = $conn->query($sql); + + if ($result->num_rows > 0) { + // 输出查询结果和编辑按钮 + while ($row = $result->fetch_assoc()) { + echo "
"; + echo "ID: " . $row["id"] . "
"; + echo "姓名: " . $row["name"] . "
"; + echo "年龄: " . $row["age"] . "
"; + echo "性别: " . $row["gender"] . "
"; + + // 在编辑页面中自动填充学生姓名 + echo "编辑"; + echo "
"; + } + } else { + echo "
没有找到相关学生信息"; + } + } + + // 关闭数据库连接 + $conn->close(); + ?> + + \ No newline at end of file