我知道这类问题已经得到了回答,但仍然没有解决我的问题。我有两张table要插进去。第一个表插入工作正常。但是第二个没有。php不会抛出任何错误。可能是我的mysql查询写得不好。
我需要尽快把这个修好。在这方面的任何帮助都是感激的。
$numb = 0; $af_f = 0; $fn = 0; $an = 0; $nt = 0; $intn = 0; $med_name = "";
$q2 = "INSERT INTO prescriptions (mr_id, mb_id, number, af_food, fn, an, nt) ";
$q2 .= "SELECT ?, MB.id, ?, ?, ?, ?, ? FROM med_batch MB INNER JOIN medicines M ON M.id = MB.med_id ";
$q2 .= "WHERE M.name = ? AND DATE(CURDATE()) < DATE_SUB(DATE(MB.exp_date), INTERVAL ? DAY) ";
$q2 .= "AND MB.stock_num > ? ORDER BY MB.arr_date LIMIT 1";
$q2 = $conn->prepare($q2) or die($conn->error);
$q2->bind_param("diiiiisii", $id, $numb, $af_f, $fn, $an, $nt, $med_name, $intn, $numb) or die($q->error);
$n = 1;
while(isset($_POST["mr-med" . $n]))
{
$intn = 0;
$med_name = $_POST["mr-med" . $n];
$numb = $_POST["mr-med-num" . $n];
$af_f = (isset($_POST["mr-af" . $n]))? 1 : 0;
$fn = (isset($_POST["mr-fn" . $n]))? 1 : 0;
$an = (isset($_POST["mr-an" . $n]))? 1 : 0;
$nt = (isset($_POST["mr-nt" . $n]))? 1 : 0;
$intn = $numb / ($fn + $an + $nt);
$intn = ceil($intn);
$q2->execute() or die($q2->error);
$n = $n + 1;
}
$r = $q2->store_result();
if($q2->affected_rows > 0)
{
echo "Successfully Added";
}
else
{
echo "Error";
}
暂无答案!
目前还没有任何答案,快来回答吧!