diff --git "a/\344\273\230\347\250\213\347\225\205/20220523\344\275\234\344\270\232.md" "b/\344\273\230\347\250\213\347\225\205/20220523\344\275\234\344\270\232.md" new file mode 100644 index 0000000000000000000000000000000000000000..bced6cb1062352f62e023b6af9767499b9da9a9f --- /dev/null +++ "b/\344\273\230\347\250\213\347\225\205/20220523\344\275\234\344\270\232.md" @@ -0,0 +1,61 @@ +```php +CREATE DATABASE student CHARSET utf8; +use student; +CREATE TABLE user( +id int NOT NULL primary key auto_increment, +name VARCHAR(20) NOT NULL, +score DECIMAL(10,2) NOT NULL +); +INSERT INTO user(name,score) VALUES ('陈小龙',98.5); +INSERT INTO user(name,score) VALUES ('吴大虫',75.5); +INSERT INTO user(name,score) VALUES ('陈得胜',66); +"; +}else{ + echo "添加失败"."
"; +} + +$delete="delete from user where id>5"; +$c=mysqli_query($a,$delete); +$cc=mysqli_affected_rows($a); +if ($cc==0){ + echo "没有相应数据,删除失败"."
"; +}else if($cc<0){ + die("运行错误"."
"); +}else{ + echo "删除成功"."
"; +} + +$update="update user set name='李白' where id=2"; +$d=mysqli_query($a,$update); +if ($update){ + echo "修改成功"."
"; +}else{ + echo "修改失败"."
"; +} + +$select="select * from user"; +$d=mysqli_query($a,$select); + +$e=mysqli_fetch_all($d); +foreach ($e as $aini){ + foreach ($aini as $taoyanni){ + echo $taoyanni." "; + } + echo "
"; +} + +while ($f=mysqli_fetch_assoc($d)){ + echo $f['id']."=".$f['name']."=".$f['score']."
"; +} +``` \ No newline at end of file