我想通过循环($ product,$ size,$ quantity,$ uom,$ target_price)在row.how中的数据库中插入多行,以便将这些类型的mutilpe行插入到database.and data.how中用于循环或其他循环输入详细记录agasint序列号1.在数据库php中添加多行?
if(isset($_POST['Submit_form']))
{
/*For Master Detail*/
$serial_no=$_POST['serial_no'];
$dated=$_POST['dated'];
$ship_schedule=$_POST['ship_schedule'];
$commission=$_POST['commission'];
$customer_name=$_POST['customer_name'];
$agnet_name=$_POST['agnet_name'];
$remark=$_POST['remark'];
/*For Detail*/
$product=$_POST['product'];
$size=$_POST['size'];
$quantity=$_POST['quantity'];
$uom=$_POST['uom'];
$target_price=$_POST['target_price'];
$sqli = "INSERT INTO inquiry_mst (dated,ship_schedule,commision,customer_id,agent_id,remarks)
VALUES ('$serial_no','$dated','$ship_schedule','$commission','$customer_name','$agnet_name','$remark')";
$sqli=$mysqli->query($sqli) or die('Failed to connect'.$mysqli->error._LINE_);
if($sqli)
{
foreach($choices as $choice => $values)
{
$sqli="INSERT INTO inquiry_dtl (serial_no, product_name,size,quantity,uom,target_price)
VALUES ($product,$size,$quantity,$uom,$target_price)";
}
}
}
首先,你需要在你的代码为什么你需要解释一个循环来做多个插入。您正在循环不在代码中的变量。所以你需要在你的问题中增加更多细节。如何创建'$ options'变量?它来自哪里?为什么一个For如果你没有使用它('$ choices')里面。解释你的需求和你的系统必须做什么将帮助我们帮助你! –
我有两个form.Master形式和详细form.in主表中包含序列号,即主键。序列号是第二种形式的foriegn键。第二种形式在同一页上给出。第二种形式多行是可交易的。这些行在数据库中反对序列号。整个表单数据的一个提交按钮在一个提交点击两个表中都存储。 – Rajo
将代码添加到您的问题对于谁会尝试回答您很重要。 –