From c8aeeee637c1b0ef309b9d958814db4a6557fe5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=88=98=E4=BD=B3=E4=B8=BD?= <2898669424@qq.com> Date: Tue, 24 May 2022 12:48:46 +0800 Subject: [PATCH] dd --- ...40\345\242\236\346\224\271\346\237\245.md" | 69 +++++++++++++++++++ 1 file changed, 69 insertions(+) create mode 100644 "\345\210\230\344\275\263\344\270\275/20220524-\345\210\240\345\242\236\346\224\271\346\237\245.md" diff --git "a/\345\210\230\344\275\263\344\270\275/20220524-\345\210\240\345\242\236\346\224\271\346\237\245.md" "b/\345\210\230\344\275\263\344\270\275/20220524-\345\210\240\345\242\236\346\224\271\346\237\245.md" new file mode 100644 index 0000000..ca1f954 --- /dev/null +++ "b/\345\210\230\344\275\263\344\270\275/20220524-\345\210\240\345\242\236\346\224\271\346\237\245.md" @@ -0,0 +1,69 @@ +作业 + +```php +"; +echo "添加了".mysqli_affected_rows($conn)."行数据";//查看受影响的行数 +echo "
"; + +//删除数据 +$sql_s="delete from `user` where id>3"; +$res_s=mysqli_query($conn,$sql_s) or die("删除数据失败!错误为:".mysqli_error($conn)); +if($res_s){ + echo "删除数据成功"; +} +echo "
"; +echo "删除了".mysqli_affected_rows($conn)."行数据";//查看受影响的行数 +echo "
"; + +//修改数据 +$sql_x="update `user` set `name`='表哥' where id=3"; +$res_x=mysqli_query($conn,$sql_x) or die("修改数据失败!错误为:".mysqli_error($conn)); +if($res_x){ + echo "修改成功"; +} +echo "
"; +echo "修改了".mysqli_affected_rows($conn)."行数据";//查看受影响的行数 +echo "
"; + +//查找数据 +$sql_c="select * from `user`"; +$res_c=mysqli_query($conn,$sql_c) or die("查找数据失败!错误为:".mysqli_error($conn)); +while($a=mysqli_fetch_assoc($res_c)){ + echo $a['id']."|".$a['name']."|".$a['score']."
"; +} +$cou=mysqli_affected_rows($conn); +if($cou>0){ + echo "查找到".$cou."行结果"; +}else if($cou==0){ + echo "无受影响"; +}else{ + echo "查询错误"; + die("查找数据失败!错误为:".mysqli_error($conn)); +} +create database student charset utf8; +use student; +create table user( +id int primary key auto_increment, +name varchar(10) not null, +score DECIMAL(3,1) not null +); +``` \ No newline at end of file -- Gitee