我需要阅读“#month;'来自表site_salmonusage。 Here是site_salmonusage中的数据示例。然后我需要计算数据是否存在,如果存在,那么我需要更新该月份的所有数据'。如果不存在,它将插入。
if ($_POST['register']){
$entry_id=$_POST["entry_id"];
$storenum = $_POST["storenum"];
$store_name=$_POST["store_name"];
$month = $_POST["month"];
$usage = $_POST["usage"];
$remove=mysqli_query($con,"SELECT COUNT(*) As count FROM site_salmonusage WHERE month='$month' AND storenum='$storenum'");
$row=mysqli_fetch_array($remove);
if($row['count']==1){
$add1 = "UPDATE site_salmonusage
SET usage='$usage'
WHERE storenum='$storenum' AND month='$month'";
}
else if($row['count']==0){
$add = "INSERT INTO site_salmonusage (storenum, month, usage)
VALUES ('$storenum','$month',$usage')";
}
else {
$del= "DELETE FROM site_salmonusage WHERE month='$month'";
$adding="INSERT INTO site_salmonusage (storenum,month,usage)
VALUES ('$storenum','$month','$usage')";
}
这是我的php。但是在提交按钮后,它不会插入到数据库中。