From 1b0ff691edfe14f2353a141493359a0908320b4f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A2=81=E8=A3=95?= <895585435@qq.com>
Date: Tue, 24 May 2022 00:18:20 +0800
Subject: [PATCH 1/2] =?UTF-8?q?=E6=8F=90=E4=BA=A4?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...01\346\224\271\343\200\201\346\237\245.md" | 91 +++++++++++++++++++
1 file changed, 91 insertions(+)
create mode 100644 "\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md"
diff --git "a/\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md" "b/\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md"
new file mode 100644
index 0000000..135f049
--- /dev/null
+++ "b/\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md"
@@ -0,0 +1,91 @@
+题目
+
+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一起提交。
+
+
+
+```mysql
+库
+
+create database student charset utf8;
+use student;
+
+表
+
+CREATE TABLE user(
+id int PRIMARY KEY auto_increment,
+name VARCHAR(20) not null,
+score decimal not null
+);`
+```
+
+
+
+```php
+";
+echo "恭喜你!成功添加了".mysqli_affected_rows($a)."行数据";//受影响行数
+echo "
";
+
+//删除数据
+$d = "delete from `user` where id>3";
+$e =mysqli_query($a,$d) or die("删除数据失败!错误为:".mysqli_error($a));
+if ($d){
+ echo "恭喜你!删除数据成功!";
+}
+echo "
";
+echo "成功删除了".mysqli_affected_rows($a)."行数据";//受影响行数
+echo "
";
+
+//修改数据
+$f ="update `user` set `name`='小白' where id=1";
+$g =mysqli_query($a,$f) or die("修改数据失败!错误为:".mysqli_error($a));
+if ($f){
+ echo "恭喜你!修改数据成功!";
+}
+echo "
";
+echo "成功修改了".mysqli_affected_rows($a)."行数据";//受影响行数
+echo "
";
+
+//查找数据
+$h = "select * from `user`";
+$j = mysqli_query($a,$h) or die("查找数据失败!错误为:".mysqli_error($a));
+while ($k=mysqli_fetch_assoc($j)){
+ echo $k['id']."/" .$k['name']."/".$k['score']."
";
+}
+$l=mysqli_affected_rows($a);
+if ($l){
+ echo "成功查找到了".$l."行数据";
+}else if ($l==0){
+ echo "无影响";
+}else{
+ echo "查询错误!";
+ die("查询数据失败!错误为:".mysqli_error($a));
+}
+```
\ No newline at end of file
--
Gitee
From 1ecfc8a18b64ae7150b16a190ee7f7a46d6f61b3 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?=E6=A2=81=E8=A3=95?= <895585435@qq.com>
Date: Mon, 23 May 2022 16:19:48 +0000
Subject: [PATCH 2/2] =?UTF-8?q?update=20=E6=A2=81=E8=A3=95/20220524-MySQL?=
=?UTF-8?q?=E5=A2=9E=E3=80=81=E5=88=A0=E3=80=81=E6=94=B9=E3=80=81=E6=9F=A5?=
=?UTF-8?q?.md.?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
...\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md" | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git "a/\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md" "b/\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md"
index 135f049..5ca3ffc 100644
--- "a/\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md"
+++ "b/\346\242\201\350\243\225/20220524-MySQL\345\242\236\343\200\201\345\210\240\343\200\201\346\224\271\343\200\201\346\237\245.md"
@@ -31,7 +31,7 @@ CREATE TABLE user(
id int PRIMARY KEY auto_increment,
name VARCHAR(20) not null,
score decimal not null
-);`
+);
```
--
Gitee