I have array of textbox
<form method="POST">
<input type="text" name="partnumber[]" value="1234">
<input type="text" name="desc[]" value="used">
<input type="text" name="qty[]" value="24">
<input type="text" name="partnumber[]" value="2345">
<input type="text" name="desc[]" value="good">
<input type="text" name="qty[]" value="31">
<input type="text" name="partnumber[]" value="3456">
<input type="text" name="desc[]" value="brand new">
<input type="text" name="qty[]" value="22">
<input type="submit">
</form>
after posting, i want to insert to my database like this. with the same ref_id.
last_insert_id = 17;
id | ref_id | partnumber| description | quantity
1 | 17 | 1234 | used | 24
2 | 17 | 2345 | good | 31
3 | 17 | 3456 | brand new | 22
any help will be appriciated. thanks..
$comma = "";
$values = "";
$last_id = 17;
foreach ($partnumber as $p) {
foreach ($desc as $d) {
foreach ($qty as $q) {
}
}
$values .= $comma."($id,$last_id,'$p','$d','$q')";
$comma = ",";
}
$sql = "INSERT INTO parts_replaced (id,last_id,partnumber,description,quantity) VALUES $values";