title: Write loop sql query from data array (php, mysql)
body: <p>I have a problem with php script.</p>
  
  <p>I have an array, which is generated from form, where <code>$_POST['store']</code> is an array from jQuery form with functionality to add multiple rows:</p>
  
  <pre><code> Array
  (
      [client] =&gt; 
      [darvad] =&gt; 
      [owca] =&gt; 
      [ldrive] =&gt; 
      [store] =&gt; Array
          (
              [product] =&gt; Array
                  (
                      [0] =&gt; 430
                      [1] =&gt; 440
                      [2] =&gt; 430
                  )
  
              [quantity] =&gt; Array
                  (
                      [0] =&gt; 123
                      [1] =&gt; 1223
                      [2] =&gt; 232
                  )
  
              [segums] =&gt; Array
                  (
                      [0] =&gt; Mixed park
                      [1] =&gt; Light vehicle
                      [2] =&gt; Trucks
                  )
  
              [deadline] =&gt; Array
                  (
                      [0] =&gt; 2015-08-04
                      [1] =&gt; 
                      [2] =&gt; 
                  )
  
              [renewal] =&gt; Array
                  (
                      [0] =&gt; 1
                  )
  
          )
  
  )
  </code></pre>
  
  <p>And i need to get values from this array into sql insert statment and loop it.</p>
  
  <p><code>$sql_rec = "INSERT INTO tsales_funnel_mrecord (product, quantity, segums, deadline)
  VALUES (...),(...),(...)....
  ";</code></p>
  
  <p>HTML CODE:</p>
  
  <pre><code>            &lt;div id="container"&gt;
              &lt;div id="content" role="main"&gt;
  
              &lt;?php
                  echo "&lt;pre&gt;";
                  print_r($_POST);
                  echo "&lt;/pre&gt;";
              ?&gt;
  
  &lt;form action="&lt;?= $_SERVER['REQUEST_URI'] ?&gt;" method="post" id=multiForm&gt;  
      &lt;label for="client"&gt;Klients: *&lt;/label&gt;&lt;input id="client" type="text" name="client" placeholder="Reg.nr | Pk.kods" value=""  /&gt;&lt;/br&gt;
      &lt;label for="selector1"&gt;Darījuma vadītājs: *&lt;/label&gt;
      &lt;select id="selector1" name="darvad" &gt;
          &lt;option value=""&gt;-Dar. vadītājs-&lt;/option&gt;
  &lt;?php 
      $sql = "SELECT Vards_Uzvards, Tables_ID FROM users";
      $results = $wpdb-&gt;get_results($sql);  // return an object, not ARRAY_N
  if ($results) {
      foreach ($results as $row) {
          echo "&lt;option value = '".$row-&gt;Tables_ID."'&gt;".$row-&gt;Vards_Uzvards."&lt;/option&gt;"; 
  }}
      echo "&lt;/select&gt;&lt;/br&gt;";                          
  ?&gt;
  &lt;label for="owcafind"&gt;&lt;a href="&lt;?php echo site_url('/sample-page/owca/'); ?&gt;" target="_blank"&gt;Meklēt OWCA kodu:&lt;/a&gt; *&lt;/label&gt;&lt;input id="owcafind" type="text" name="owca" placeholder="OWCA Kods (8)" value=""  /&gt;&lt;/br&gt;
  
  &lt;label for="ldrive"&gt;Mape L diskā:&lt;/label&gt;&lt;input id="ldrive" type="text" name="ldrive" placeholder="Mape L diskā" value="" /&gt;&lt;/br&gt;
  
  Produkti:  &lt;a href="#" class="addRow"&gt;&lt;img src="&lt;?php echo site_url('/img/plus-icon.png'); ?&gt;" width="15px"&gt;&lt;/a&gt;&lt;br/&gt;
  &lt;table class="multi"&gt;
  &lt;!-- table title --&gt;
  &lt;tr&gt;&lt;th&gt;Produkts&lt;/th&gt;&lt;th&gt;Vienību skaits&lt;/th&gt;&lt;th&gt;Riska segums:&lt;/th&gt;&lt;th&gt;Deadline:&lt;/th&gt;&lt;th&gt;Atjaunojums&lt;/th&gt;&lt;th&gt;[Option]&lt;/th&gt;&lt;/tr&gt;
  &lt;!-- row template, when added new row --&gt;
  &lt;tr style="display:none;" class="templateRow"&gt;
  &lt;td&gt;&lt;select name="store[product][]"&gt;
  &lt;option value="" selected="selected"&gt;-Produkts-&lt;/option&gt;
  &lt;option value="430"&gt;OCTA&lt;/option&gt;
  &lt;option value="440"&gt;KASKO&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="store[quantity][]" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;select name="store[segums][]"&gt;
  &lt;option value="" selected="selected"&gt;-Riska segums-&lt;/option&gt;
  &lt;option value="Mixed park"&gt;Mixed park&lt;/option&gt;
  &lt;option value="Light vehicle"&gt;Light vehicle&lt;/option&gt;
  &lt;option value="Trucks"&gt;Trucks&lt;/option&gt;
  &lt;option value="Buss"&gt;Buss&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="date" name="store[deadline][]" class="datepicker" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" name="store[renewal][]" value="1" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;a class="del" href="#"&gt;&lt;img src="&lt;?php echo site_url('img/minus-icon.jpg'); ?&gt;" width="15px"&gt;&lt;/a&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;!-- default values --&gt;
  &lt;tr&gt;
  &lt;td&gt;&lt;select name="store[product][]" &gt;
  &lt;option value="" selected="selected"&gt;-Produkts-&lt;/option&gt;
  &lt;option value="430"&gt;OCTA&lt;/option&gt;
  &lt;option value="440"&gt;KASKO&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="store[quantity][]"  /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;select name="store[segums][]"&gt;
  &lt;option value="" selected="selected"&gt;-Riska segums-&lt;/option&gt;
  &lt;option value="Mixed park"&gt;Mixed park&lt;/option&gt;
  &lt;option value="Light vehicle"&gt;Light vehicle&lt;/option&gt;
  &lt;option value="Trucks"&gt;Trucks&lt;/option&gt;
  &lt;option value="Buss"&gt;Buss&lt;/option&gt;
  &lt;/select&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="date" name="store[deadline][]" class="datepicker"  /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="checkbox" name="store[renewal][]" value="1" /&gt;&lt;/td&gt;
  &lt;td&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;!-- /default values --&gt;
  &lt;/table&gt;
  </code></pre>