From 4317c8fc00cd24b524607f901204f84854adcda7 Mon Sep 17 00:00:00 2001
From: unknown <2576065650@qq.com>
Date: Mon, 23 May 2022 23:33:08 +0800
Subject: [PATCH] d
---
...36\345\210\240\346\224\271\346\237\245.md" | 84 +++++++++++++++++++
1 file changed, 84 insertions(+)
create mode 100644 "\350\246\203\346\270\270/20220523-MySQL\345\242\236\345\210\240\346\224\271\346\237\245.md"
diff --git "a/\350\246\203\346\270\270/20220523-MySQL\345\242\236\345\210\240\346\224\271\346\237\245.md" "b/\350\246\203\346\270\270/20220523-MySQL\345\242\236\345\210\240\346\224\271\346\237\245.md"
new file mode 100644
index 0000000..258a74f
--- /dev/null
+++ "b/\350\246\203\346\270\270/20220523-MySQL\345\242\236\345\210\240\346\224\271\346\237\245.md"
@@ -0,0 +1,84 @@
+# 作业
+
+1.MySQL中新建个student数据库,里面有个学生信息表user,表结构和内容如下:
+
+| 字段 | 类型 | 备注 |
+| ----- | ------- | ---------- |
+| id | int | 自增,主键 |
+| name | varchar | 非空 |
+| score | decimal | 非空 |
+
+| 1 | 陈小龙 | 98.5 |
+| ---- | ------ | :--- |
+| 2 | 吴大虫 | 75.5 |
+| 3 | 陈得胜 | 66 |
+
+2.完成PHP访问数据库五步,使用MySQL扩展对MySQL数据库中的学生信息表进行增删改查。
+
+3.交作业时,要把MySQL相关代码和PHP一起提交。
+
+
+
+```php
+";
+
+
+//2.删除数据
+$b = "delete from `user` where `id` = 1";
+$da = mysqli_query($hiuh,$b) or die ("删除失败!").mysqli_error($hiuh);
+if(da){
+ echo"删除成功!";
+}
+
+echo "
";
+
+
+//3.修改数据
+$c = "update `user` set `score` = 95 where `id` = 2";
+$dc = mysqli_query($hiuh,$c);
+if ($dc){
+ echo "修改成功!";
+}else{
+ echo"修改失败!";
+}
+
+echo "
";
+
+
+
+//4.查询数据
+$d = "select * from `user`";
+$ds= mysqli_query($hiuh,$d) or die ("发生错误".mysqli_error($hiuh ));
+while ($ss = mysqli_fetch_assoc($ds)) {
+ echo $ss['id'] . " " . $ss['name'] . " " . $ss['score'] . "
";
+}
+$hj=mysqli_affected_rows($hiuh);
+if($hj>0){
+ echo "查找到".$hj."行结果";
+}else if($hj==0){
+ echo "无受影响";
+}else{
+ echo "查询错误";
+ die("查找数据失败!错误为:".mysqli_error($hiuh));
+}
+```
\ No newline at end of file
--
Gitee