title: Codeigniter Insert Multiple Rows in SQL
body: <p>I am fresh to Codeigniter. I have  a form which looks something like this.  </p>
  
  <pre><code>&lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="Name[0]" value=""&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="Address[0]"  value=""&gt;&lt;br&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="Age[0]" value=""&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="Email[0]" value=""&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  
  
  &lt;tr&gt;
  &lt;td&gt;&lt;input type="text" name="Name[1]" value=""&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="Address[1]"  value=""&gt;&lt;br&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="Age[1]" value=""&gt;&lt;/td&gt;
  &lt;td&gt;&lt;input type="text" name="Email[1]" value=""&gt;&lt;/td&gt;
  &lt;/tr&gt;
  </code></pre>
  
  <p>There may be from 0 to n rows, usually 5 to 10 rows. How do I insert them in SQL? Is this possible with Codeigniter or should I use a native PHP script?</p>
  
  <hr>
  
  <pre><code>$name=$_POST['Name'];
  $address=$_POST['Address'];
  $age=$_POST['Age'];
  $email=$_POST['Email'];
  $count = count($_POST['Name']);
  
  
  
  for($i=0; $i&lt;$count; $i++) {
  $data = array(
             'name' =&gt; $name[$i], 
             'address' =&gt; $address[$i],
             'age' =&gt; $age[$i],
             'email' =&gt; $email[$i],
  
             );
  
  
    $this-&gt;db-&gt;insert('mytable', $data);
  }
  </code></pre>
  
  <p>I did this. It works. But the solution seems inelegant.</p>
  
  <p>kevtrout's answer looks better but is currently throwing a lot of errors.</p>
  
  <p>Is there any way to insert all data at one go?</p>