刪除
<?php
$did=$_REQUEST['did'];//獲取did的值
$conn=mysqli_connect('127.0.0.1','root','','數(shù)據(jù)庫名字',3306);//固定
$sql="SET NAMES UTF8";//設(shè)置編碼
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');//相應(yīng)頭部
$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';
}
查找以數(shù)組的形式輸出
<?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);