【发布时间】:2017-02-15 02:00:07
【问题描述】:
这是一个订单 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[]"。 提前致谢。
【问题讨论】:
-
你应该养成accepting the appropriate answer的习惯(它对你有用或解决了你的问题)。它将鼓励其他开发人员进一步帮助您。
-
另外,显示您的 HTML 表单。