I am trying to export a full table into SQL using data from an HTML table. I know how to export one row, but can't understand how to export multiple rows. Any advice?
<?php while ($row = $result->fetch_assoc()) :?>
<tr>
<form action="insertorder.php" method="post">
<td name="Item_ID[]"><?=$row["item_id"]?></td>
<td name="name[]"><?=$row["ITEM_NAME"]?></td>
<td name="suggested_qty"><?=$row["suggested_qty"]?></td>
<td name="price" class="pricetd"><?=$row["Price_item"]?></td>
<td>
<input type="text" name="editedvalues[]" class="qtyinput" value="<?=$row["suggested_qty"]?>" />
</td>
<td><input name='result[]' class="resultinput" /></td>
</tr>
<?php endwhile?>
<input type="submit" class="btn btn-dark" value="Submit">
</table>
</form>
//////Export script////////
$sql = 'INSERT INTO \'ms_order\' (\'item_id\', \'item_name\', \'order_quantity\', \'total\') VALUES';
for ($i=0; $i<count($_POST['item_id']); $i++) {
$sql .= '(\'' . $_POST['item_id'][$i] . '\', \'' . $_POST['item_name'][$i] . '\', \'' . $_POST['editedvalues[]'][$i] . '\', \'' . $_POST['result'][$i] . '\')';
if ($i<count($_POST['item_id']) - 1) {
$sql .= ',';
}
}