title: insert values using array value dynamically in PDO
body: <p>I'm having problem to Insert array values into database table. This is my project to create invoice using dynamically added (with js) new rows with array value into database table. 
  my code in php(PDO) is as below: 
  my form values are as: 
  MY COMPLETE CODE IS: </p>
  
  <pre><code>&lt;form method="post"&gt;
  &lt;?php $party = $_GET['party'];  
  $sq = $conn-&gt;query("SELECT * FROM invoice WHERE invoice_id = '$party'");
  $ro = $sq-&gt;fetch(PDO::FETCH_OBJ);
  echo "Invoice for ".$ro-&gt;party;
  ?&gt;
   &lt;table class="table table-bordered table-hover" width="800"&gt;
  &lt;thead&gt;
  &lt;tr&gt;
  &lt;th&gt; No &lt;/th&gt;
  &lt;th&gt; Particulars&lt;/th&gt;
  &lt;th&gt; Quantity&lt;/th&gt;
  &lt;th&gt; Price&lt;/th&gt;
  &lt;th&gt; Discount&lt;/th&gt;
   &lt;th&gt; Amount&lt;/th&gt;
  &lt;th&gt; &lt;input type="button" value="+" id="add" class="btn btn-primary" /&gt; &lt;/th&gt;
  &lt;/tr&gt;
  &lt;/thead&gt;
  &lt;tbody class="detail"&gt;
  &lt;input type="hidden" name="invoice_id[]" value="&lt;?php echo $ro-&gt;invoice_id; ?&gt;" /&gt;
  &lt;tr&gt;
  &lt;td class="no"&gt;1 &lt;/td&gt;
  
  
  &lt;input type="text" class="form-control productname" name="product_name[]" /&gt; 
  &lt;td&gt;&lt;input type="text" class="form-control quantity" name="quantity[]" /&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="form-control price" name="price[]" /&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="form-control discount" name="discount[]" /&gt; &lt;/td&gt;
  &lt;td&gt;&lt;input type="text" class="form-control amount" name="amount[]" /&gt; &lt;/td&gt;
  &lt;td&gt; &lt;a href="#" class="remove"&gt;Delete &lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/tbody&gt;
   &lt;input type="submit" class="btn btn-primary" name="save" value="Save invoice" /&gt;
  
  
  
  &lt;/form&gt;
  </code></pre>
  
  <p>AND I WRITE JAVASCRIPT TO ADD AND DELETE ROW OF ABOVE TABLE TO ADD /DELETE VALUES. </p>
  
  <pre><code>&lt;?php 
   if (isset($_POST['save'])) {
  $invoice_id = $_GET['party'];
  $product_name = $_POST['product_name'];
  $quantity = $_POST['quantity'];
  $price = $_POST['price'];
  $discount = $_POST['discount'];
  $amount = $_POST['amount'];
  for($i;$i&lt;count($_POST['product_name']);$i++){
   $stmt = $conn-&gt;query("insert into invoicesubcategory (invoice_id,product_name,quantity,price,discount,amount)
  values ('$invoice_id','$product_name','$quantity','$price','$discount','$amount')");
  
  $stmt-&gt;bindParam( ':invoice_id', $invoice_id , PDO::PARAM_STR );
  $stmt-&gt;bindParam( ':product_name', $product_name, PDO::PARAM_STR ); 
  $stmt-&gt;bindParam( ':quantity', $quantity , PDO::PARAM_STR );
  $stmt-&gt;bindParam( ':price', $price , PDO::PARAM_STR );
  $stmt-&gt;bindParam( ':discount', $discount, PDO::PARAM_STR );
  $stmt-&gt;bindParam( ':amount', $amount , PDO::PARAM_STR );
   header("location:invoicesubcat.php");  
  }} ?&gt;
  </code></pre>
  
  <p>I need help, how to insert values, in array, using PDO?
  The problem is, my codes, inserting values into db table like this: </p>
  
  <pre><code>83  7   Array   Array   Array   0   Array
  </code></pre>