From fb7f3121b0f964f437ad6a61f35a92781101191e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=B6=E6=80=9D=E6=80=9D?= <3242902095@qq.com> Date: Tue, 24 May 2022 00:06:01 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...07\344\273\266\344\270\212\344\274\240.md" | 0 ...16\345\242\236\345\210\240\346\224\271.md" | 73 +++++++++++++++++++ 2 files changed, 73 insertions(+) rename "\345\217\266\346\200\235\346\200\235/200220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" => "\345\217\266\346\200\235\346\200\235/20220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" (100%) create mode 100644 "\345\217\266\346\200\235\346\200\235/20220523-\350\277\236\346\216\245\344\270\216\345\242\236\345\210\240\346\224\271.md" diff --git "a/\345\217\266\346\200\235\346\200\235/200220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" "b/\345\217\266\346\200\235\346\200\235/20220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" similarity index 100% rename from "\345\217\266\346\200\235\346\200\235/200220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" rename to "\345\217\266\346\200\235\346\200\235/20220518-\346\226\207\344\273\266\344\270\212\344\274\240.md" diff --git "a/\345\217\266\346\200\235\346\200\235/20220523-\350\277\236\346\216\245\344\270\216\345\242\236\345\210\240\346\224\271.md" "b/\345\217\266\346\200\235\346\200\235/20220523-\350\277\236\346\216\245\344\270\216\345\242\236\345\210\240\346\224\271.md" new file mode 100644 index 0000000..e33c963 --- /dev/null +++ "b/\345\217\266\346\200\235\346\200\235/20220523-\350\277\236\346\216\245\344\270\216\345\242\236\345\210\240\346\224\271.md" @@ -0,0 +1,73 @@ +```mysql +#建立student数据库 +create database student charset utf8; +use student; +#建立user信息表 +create table user( +id int primary key auto_increment, +name varchar(20) not null, +score decimal(5,2) not null +); +``` + +```php +"; + +//添加数据 +mysqli_query($con,'set name utf8');//为了让添加的数据不会乱码 +$tt="insert into `user`(`name`,`score`) values('陈小龙',98.5),('陈大虫',75.5),('陈得胜',66)"; +$result=mysqli_query($con,$tt); +if ($result){ + echo "添加数据成功"; +}else{ + die("添加数据失败,出现错误:".mysqli_error($con)); +} +echo "
"; + +//增加数据 +$zz="insert into `user`(`name`,`score`) value('张三',88)"; +$result=mysqli_query($con,$zz); +if ($result){ + echo "增加数据成功"; +}else{ + die("增加数据失败,出现错误:".mysqli_error($con)); +} +echo "
"; + +//修改数据 +$xx="update `user` set `name`='李四' where id=1"; +$result=mysqli_query($con,$xx); +if ($result){ + echo "修改数据成功"; +}else{ + die("修改数据失败,出现错误:".mysqli_error($con)); +} +echo "
"; + +//删除数据 +$ss="delete from `user` where id>3"; +$result=mysqli_query($con,$ss); +if ($result){ + echo "删除数据成功"; +}else{ + die("删除数据失败,出现错误".mysqli_error($con)); +} +echo "
"; + +//查找数据 +$cc="select * from `user`"; +$result=mysqli_error($con,$cc) or die("查找数据失败,出现错误".mysqli_error($con)); +while ($aa=mysqli_fetch_assoc($result)){ + echo $aa['id']." ".$aa['name']." ".$aa['score']; +} + +``` + -- Gitee