diff --git "a/\346\235\250\351\221\253\344\273\252/20220523-php\346\225\260\346\215\256\345\272\223.md" "b/\346\235\250\351\221\253\344\273\252/20220523-php\346\225\260\346\215\256\345\272\223.md" new file mode 100644 index 0000000000000000000000000000000000000000..a053631d144f5a57625f756cf850357ac072d886 --- /dev/null +++ "b/\346\235\250\351\221\253\344\273\252/20220523-php\346\225\260\346\215\256\345\272\223.md" @@ -0,0 +1,54 @@ +```sql +-- Mysql中新建个student数据库,里面有个学生信息表user +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 +); +``` +```php +// 完成PHP访问数据库五步。使用mysqli扩展对mysql数据库中的学生信息表进行增删改查。 + +"; +}else{ + echo "添加数据失败
"; +} +echo "
"; +//删除数据 +$sc= "delete from `user` where `id`=3"; +$result1= mysqli_query($conn,$sc); +if ($result1){ + echo "删除数据成功 "; +}else{ + echo "删除数据失败 "; +} +echo"
"; +//修改数据 +$xiugai= "update `user` set `score`='55' where `id`=2 "; +$result2 = mysqli_query($conn,$xiugai); +if ($result2){ + echo "修改数据成功"; +}else{ + echo "修改数据失败"; +} +echo "
"; +//查找数据 +$chazhao = "select * from `user` where 'score'=66 "; +$result3 = mysqli_query($conn,$chazhao) or die("查找数据失败
"); +while($a=mysqli_fetch_assoc($result3) ){ + echo $a['id']." ".$a['name']." ".$a['score']."
"; +} +```