如果从条件发送嵌套的MySQL查询时,我将重定向到同一页面,但该查询似乎无法正常工作。
这是我的嵌套查询。
在这里,我正在接收来自表单的字符串输入,并希望将其发送到数据库。但是此查询不适用于cpanel托管。虽然这适用于本地XAMPP堆栈。
if (isset($_POST['submit_pending'])) {
$pendingParticulars = $_POST['gr_particulars'];
$pendingUnit = $_POST['gr_unit'];
$pendingRate = $_POST['gr_rate'];
$pendingReceived = $_POST['gr_updateReceived'];
$poNumber = $_POST['gr_number'];
$pendingAmount = $pendingRate * $pendingReceived;
$requiredUnit = $pendingUnit - $pendingReceived;
$excess = $pendingReceived - $pendingUnit;
$excess = max(0, $excess);
$requiredUnit = max(0, $requiredUnit);
$pendingShortage = $pendingUnit - $pendingReceived;
if ($requiredUnit == 0) {
$submitGoodsQuery = "INSERT INTO goods_received (po_number, particulars, unit, actual_received, shortage, accepted, rejected, pending, rate, amount, status) VALUES ('$poNumber', '$pendingParticulars', '$pendingUnit', '$pendingReceived', '$requiredUnit', '$pendingReceived', 0, '$requiredUnit', '$pendingRate', '$pendingAmount', 'Received')";
$submitGoodsResult = mysqli_query($connection, $submitGoodsQuery);
if ($submitGoodsResult) {
$updateGoodsPO = mysqli_query($connection, "DELETE FROM pending_goods WHERE po_number = '$poNumber' ");
header("Refresh:0");
}
} elseif ($requiredUnit > 0) {
$submitGoodsQuery = "INSERT INTO goods_received (po_number, particulars, unit, actual_received, shortage, excess, accepted, rejected, pending, rate, amount, status) VALUES ('$poNumber', '$pendingParticulars', '$pendingUnit', '$pendingReceived', '$pendingShortage', 0, '$pendingReceived', 0, '$requiredUnit', '$pendingRate', '$pendingAmount', 'Received')";
$submitGoodsResult = mysqli_query($connection, $submitGoodsQuery);
if ($submitGoodsResult) {
$newPoNumberQue = mysqli_query($connection, "SELECT pending_number FROM pending_goods WHERE po_number = '$poNumber' AND po_particulars = '$pendingParticulars' ORDER BY serial_number DESC ");
$pendingCount = mysqli_num_rows($newPoNumberQue);
$updateGoodsPO = mysqli_query($connection, "DELETE FROM pending_goods WHERE po_number = '$poNumber' ");
$insertNewVals = mysqli_query($connection, "INSERT INTO pending_goods (po_number, po_particulars, po_quantity, po_RateWithGst, goods_status) VALUES ('$poNumber', '$pendingParticulars', '$pendingShortage', '$pendingRate', 'Partially') ");
header("Refresh:0");
}
}
} // End submit pending
} // End get pending