I badly needed this solution.
Here is the image what I will checked:
这是订单 ID。它对于所有问题标题都是通用的。
它将像这样插入:
这是我使用的代码:
if(isset($_POST['Submit'])){
try{
$orderNo = $_SESSION['orderNo'];
$serviceTitle=$_POST['serviceTitle'];
$price= $_POST['price'];
$quantity= $_POST['quantity'];
$amount= $_POST['amount'];
for ($i=0; $i<count($serviceTitle); $i++){
$statement = $db->prepare("INSERT INTO invoice (orderNo,productName,price,quantity,amount) VALUES (?,?,?,?,?)");
$statement->execute(array($orderNo,$serviceTitle[$i],$price[$i],$quantity[$i],$amount[$i]));
}
header("location: order_confirm_tech_step1.php");
}
catch(Exception $e) {
$error_message = $e->getMessage();
}
}
我使用的每个数组输入如下:name =“serviceTitle []”。
提前致谢。
为什么不试试这个,在执行查询之前检查复选框是否被选中
if(isset($_POST['Submit'])){
try{
$orderNo = $_SESSION['orderNo'];
$serviceTitle=$_POST['serviceTitle'];
$price= $_POST['price'];
$quantity= $_POST['quantity'];
$amount= $_POST['amount'];
for ($i=0; $i<count($serviceTitle); $i++){
if(!empty($_POST['checkbox'][$i])) {
$statement = $db->prepare("INSERT INTO invoice (orderNo,productName,price,quantity,amount) VALUES (?,?,?,?,?)");
$statement->execute(array($orderNo,$serviceTitle[$i],$price[$i],$quantity[$i],$amount[$i]));
}
}
header("location: order_confirm_tech_step1.php");
}
catch(Exception $e) {
$error_message = $e->getMessage();
}
}
注意:名称=“复选框[]”
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)