can't figure out how to insert multiple inputs to database using mysql. what am trying to do is to make an order form where you could insert multiple items each item has a quantity and price to it. should i use the same field name for each input followed with [] to make it an array. then how would the insert sql would look like?
<form action="processinvoice.php" method="post">
<label>Invoice Number</label>
<input type="text" name="invoicenumber" value="Enter Invoice Number">
<p><label>Vendor's ID</label>
<input type="text" name="vendorid" value="Enter Vendor's ID"></p>
<!-- Product code begining -->
<label>Items sold</label>
<select name="proid[]" >
<?php
$stmt = $dbcon->prepare("SELECT * FROM products");
$stmt->execute();
while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<option value=" <?php echo $pid; ?> "><?php echo $pname; ?></option>
<?php
} ?>
</select>
<label>Quantity</label>
<input type="text" name="tquantity[]" value="Enter quantity">
<label>Price</label>
<input type="text" name="saleprice[]" value="Enter price">
<p></p><select name="proid[]" >
<?php
$stmt = $dbcon->prepare("SELECT * FROM products");
$stmt->execute();
while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<option value=" <?php echo $pid; ?> "><?php echo $pname; ?></option>
<?php
} ?>
</select>
<label>Quantity</label>
<input type="text" name="tquantity[]" value="Enter quantity">
<label>Price</label>
<input type="text" name="saleprice[]" value="Enter price">
<p></p><select name="proid[]" >
<?php
$stmt = $dbcon->prepare("SELECT * FROM products");
$stmt->execute();
while ($row=$stmt->fetch(PDO::FETCH_ASSOC)) {
extract($row);
?>
<option value=" <?php echo $pid; ?> "><?php echo $pname; ?></option>
<?php
} ?>
</select>
<label>Quantity</label>
<input type="text" name="tquantity[]" value="Enter quantity">
<label>Price</label>
<input type="text" name="saleprice[]" value="Enter price">
<!-- Product code END -->
<input type="submit" name="submit" value="submit">
WHAT AM TRYING TO DO IS: inserting multiple items connected with quantity and price for each. all of the items will be showing the same invoice number and vendor id.