删除
<?php
$did=$_REQUEST['did'];//获取did的值
$conn=mysqli_connect('127.0.0.1','root','','数据库名字',3306);//固定
$sql="SET NAMES UTF8";//设置编码
mysqli_query($conn,$sql);
$sql="DELETE FROM dish WHERE did='$did'";//删除dish列表中的did;
$result=mysqli_query($conn,$sql);//输出
if($result===true){//判断是否正确
echo '删除成功';
echo "<a href='dish_select.php'>查看全部</a>";
}else{
echo '删除失败';
}
?>
查找//登录查找
<?php
header('Content-Type:text/plain');//相应头部
$name=$_REQUEST['name'];
$word=$_REQUEST['word'];
$conn=mysqli_connect('127.0.0.1','root','','one',3306);
$sql="SET NAMES UTF8";
mysqli_query($conn,$sql);
$sql="SELECT * FROM wsp WHERE name='$name' AND word='$word'";
$reg=mysqli_query($conn,$sql);
$row=mysqli_fetch_assoc($reg);
if($row===null){
echo 'err';
}else{
echo 'succ';
}
查找以数组的形式输出
<?php
header('Content-Type:application/json');
$pic1=$_REQUEST['pic1'];
$conn=mysqli_connect('127.0.0.1','root','','one',3306);
$sql="SET NAMES UTF8";
mysqli_query($conn,$sql);
$sql="SELECT * FROM sol WHERE pic1='$pic1'";
$reg=mysqli_query($conn,$sql);
$all=mysqli_fetch_all($reg,MYSQLI_ASSOC);
echo json_encode($all);