[英]Delete rows from multiple tables in mysqli query
How can I delete from multiple tables if all tables have common value here used code but doesn't work 如果所有表都具有共同值,该如何从多个表中删除?
<?php
include_once("config.php");
$order_no = $_REQUEST['id'];
$order_date = $_REQUEST['date'];
$conn->query("DELETE FROM `orders` WHERE `date`='$order_date' and `order_no`='$order_no';
DELETE FROM `customer_order` WHERE `order_date`='$order_date' and `order_no`='$order_no';
DELETE FROM `driver_order` WHERE `order_date`='$order_date' and `order_no`='$order_no';");
header('location:index.php');
?>
You have a $date
variable but use $order_date
in your query. 您有一个$date
变量,但在查询中使用$order_date
。
Please note this is not safe way of doing it. 请注意,这不是安全的方法。 Look for SQL Injection. 寻找SQL注入。
SOLVED 解决了
<?php
include_once("config.php");
$order_no = $_REQUEST['id'];
$order_date = $_REQUEST['date'];
$conn->query("DELETE `orders`,`customer_order`,`driver_order`
FROM `orders`,`customer_order`,`driver_order`
WHERE `orders`.`date`='$order_date' and `orders`.`order_no`='$order_no' AND
`customer_order`.`order_date`='$order_date' and `customer_order`.`order_no`='$order_no' AND
driver_order
. driver_order
。 order_date
='$order_date' and driver_order
. order_date
='$ order_date'和driver_order
。 order_no
='$order_no';"); header('location:index.php'); order_no
='$ order_no';“);标头('location:index.php');
?>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.