title: Inserting multiple rows to database table from a form
body: <p>I have a checklist form that managers can fill out. And at the bottom, they type out a material list that their employees can sign off on when complete. The amount of materials can be as long as 20+ rows. Below is what the rows they fill out contain:</p>
  
  <pre><code>        &lt;tr&gt;&lt;td&gt;&lt;button type="button" class="addRow"&gt;Add Row&lt;/button&gt;&lt;/td&gt;&lt;/tr&gt;
          &lt;tr&gt;&lt;th&gt;WO# / Date &lt;br/&gt;(if added or changed after Revision 1)&lt;th&gt;Component Name and Number&lt;/th&gt;&lt;th&gt;Finish Sizes&lt;/th&gt;&lt;th&gt;Material&lt;/th&gt;&lt;th&gt;Total # Pieces&lt;/th&gt;&lt;th&gt;Work Order&lt;/th&gt;&lt;th&gt;Notes&lt;/th&gt;&lt;th&gt;Work Order&lt;/th&gt;&lt;th&gt;Notes&lt;/th&gt;&lt;th&gt;Work Order&lt;/th&gt;&lt;th&gt;Notes&lt;/th&gt;&lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;input type="text" name='wo_num_and_date'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name='comp_name_and_num'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name='finish_sizes'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name='material'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name='total_num_pieces'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name='workorder_num_one'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea rows="2" cols="12" name='notes_one'&gt;&lt;/textarea&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name='workorder_num_two'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea rows="2" cols="12" name='notes_two'&gt;&lt;/textarea&gt;&lt;/td&gt;
              &lt;td&gt;&lt;input type="text" name='workorder_num_three'/&gt;&lt;/td&gt;
              &lt;td&gt;&lt;textarea rows="2" cols="12" name='notes_three'&gt;&lt;/textarea&gt;&lt;/td&gt;
          &lt;/tr&gt;
  </code></pre>
  
  <p>It starts out with just 1 fillable row and then I've got some jquery that allows them to add more rows.</p>
  
  <p>My insert script below is only inserting the first row in my form. </p>
  
  <pre><code>if(isset($_POST['submit'])){
     $user = getuserinfo($loggedin_id);
     $posted_date = $_POST['posted_date'];
     $revision = $_POST['revision'];
     $per_wo_num = $_POST['per_wo_num'];
     $category = $_POST['category'];
  
     $wo_num_and_date = $_POST['wo_num_and_date'];
     $comp_name_and_num = $_POST['comp_name_and_num'];
     $finish_sizes = $_POST['finish_sizes'];
     $material = $_POST['material'];
     $total_num_pieces = $_POST['total_num_pieces'];
     $workorder_num_one = $_POST['workorder_num_one'];
     $notes_one = $_POST['notes_one'];
     $workorder_num_two = $_POST['workorder_num_two'];
     $notes_two = $_POST['notes_two'];
     $workorder_num_three = $_POST['workorder_num_three'];
     $notes_three = $_POST['notes_three'];
  
  
  $sql = "INSERT INTO checklist_revision (job_num, user_id, revision_num, category, posted_date, per_workorder_number)
  VALUES ($job_num,
          $loggedin_id,
          $revision,
          $category,
          STR_TO_DATE('$posted_date', '%Y-%m-%d'),
          $per_wo_num);";
  
   mysqli_query($dbc3, $sql);
  
  
  $revision_id = mysqli_insert_id($dbc3);
  
  $sql2 = "INSERT INTO checklist_component_stock (revision, job_num, category, posted_date, wo_num_and_date, comp_name_and_number, finish_sizes, material, total_num_pieces, workorder_num_one, notes_one, signoff_user_one, workorder_num_two, notes_two, signoff_user_two, workorder_num_three, notes_three, signoff_user_three)
  VALUES ('$revision_id',
          '$job_num',
          '$category',
          STR_TO_DATE('$posted_date', '%Y-%m-%d'),
          '$wo_num_and_date',
          '$comp_name_and_num',
          '$finish_sizes',
          '$material',
          '$total_num_pieces',
          '$workorder_num_one',
          '$notes_one',
          NULL,
          '$workorder_num_two',
          '$notes_two',
          NULL,
          '$workorder_num_three',
          '$notes_three',
          NULL);";
  
   mysqli_query($dbc3, $sql2);
  </code></pre>
  
  <p>How do I make it so no matter how many rows they add, it inserts them all into the table instead of just the first row?</p>
  
  <p>VAR DUMP after trying Huseyin's answer:</p>
  
  <pre><code>array (size=17)
    'submit' =&gt; string 'Submit!' (length=7)
    'posted_date' =&gt; string '2014-04-07' (length=10)
    'category' =&gt; string '1' (length=1)
    'revision' =&gt; string '4' (length=1)
    'revisionDate' =&gt; string '2014-04-07' (length=10)
    'per_wo_num' =&gt; string '2' (length=1)
    'wo_num_and_date' =&gt; string 'WO#5/2013-04-04' (length=15)
    'comp_name_and_num' =&gt; string 'Lift 2' (length=6)
    'finish_sizes' =&gt; string '2x2x2' (length=5)
    'material' =&gt; string 'P20' (length=3)
    'total_num_pieces' =&gt; string '1' (length=1)
    'workorder_num_one' =&gt; string '1' (length=1)
    'notes_one' =&gt; string 'OK' (length=2)
    'workorder_num_two' =&gt; string '2' (length=1)
    'notes_two' =&gt; string 'OK' (length=2)
    'workorder_num_three' =&gt; string '3' (length=1)
    'notes_three' =&gt; string 'NOT OK' (length=6) 
  </code></pre>