$name =$_GET["name"];
$db = new MySQLi("localhost","root","112834","test4");
$sql = "delete from hao where name='{$name}'";
$r = $db->query($sql);
if($r)
{
header("location:biaoge.php");
}
else
{
echo "删除失败";
}
<h1>添加</h1>
<form action="tianjia.php" method="post">
<div>名称 <input type="text" name="name" /></div>
<div>价格 <input type="text" name="price" /></div>
<div>产地 <input type="text" name="chandi" /></div>
<div>库存 <input type="text" name="numbers" /></div>
<div><input type="submit" value="添加" /></div>
</form>
<?php
$name = $_POST["name"];
$price = $_POST["price"];
$chandi = $_POST["chandi"];
$numbers = $_POST["numbers"];
$db = new MySQLi("localhost","root","112834","test4");
$sql = "insert into hao values ('','{$name}','{$price}','{$chandi}',{$numbers})";
$r = $db->query($sql);
if($r)
{
header("location:biaoge.php");
}
else
{
echo "添加失败";
}
?>