title: How to Insert Arrays (Multiple rows) into Mysql using Codeigniter?
body: <p>i have search alot and i have post somany times but i didnt get any proper answer. </p>
  
  <p>This is my view page - <a href="http://jsfiddle.net/Pravin_com/r2osyj1x/#&amp;togetherjs=yiU1jT4l7G" rel="nofollow noreferrer">View</a></p>
  
  <p>here i have write a query for add fields dynamically for particular <strong>ref_no</strong> so help me for <strong>model</strong> and <strong>controller</strong></p>
  
  <pre><code>&lt;div id="login_form"&gt;
          &lt;?php echo form_open(base_url().'sample/invoice'); ?&gt;
          &lt;label for="type" class="control-label"&gt;Type&lt;/label&gt;
          &lt;div&gt;&lt;?php echo form_input(array('id'=&gt;'type','name'=&gt;'type'));?&gt;&lt;/div&gt;
  
          &lt;label for="ref" class="control-label"&gt;REF&lt;/label&gt;
          &lt;div&gt;&lt;?php echo form_input(array('id'=&gt;'ref','name'=&gt;'ref'));?&gt;&lt;/div&gt;
  
          &lt;label for="title" class="control-label"&gt;TITLE&lt;/label&gt;
          &lt;div&gt;&lt;?php echo form_input(array('id'=&gt;'title','name'=&gt;'title'));?&gt;&lt;/div&gt;
  
          &lt;div  id="description"&gt;&lt;p id="add_field"&gt;ADD DESCRIPTION&lt;/p&gt;&lt;/div&gt;
  
          &lt;label for="doc" class="control-label"&gt;Support Doc&lt;/label&gt;
          &lt;div&gt;&lt;?php echo form_input(array('id'=&gt;'doc','name'=&gt;'attach','type'=&gt;"file"));?&gt;&lt;/div&gt;
  
          &lt;input id="btn_add" name="btn_add" type="submit" class="btn btn-primary" value="Save" /&gt;
      &lt;/div&gt;
  &lt;script&gt;
              var count = 0;
      $(document).ready(function() {
          $('p#add_field').click(function(){
             count += 1;
              var html='&lt;strong&gt;Description  '+ count +'&lt;/strong&gt;'+'&lt;input id="description'+ count +'"name="description[]'+'" type="text" /&gt;'+'&lt;input id="description'+ count +'"name="voucher_no[]'+'" type="text" /&gt;'+'&lt;input id="description'+ count +'"name="price[]'+'" type="text" /&gt;&lt;br /&gt;';
              $('#description').append(html);
  
      });
      });
  
          &lt;/script&gt;
  </code></pre>
  
  <p>This is My Controller :</p>
  
  <pre><code>$data1 = array(
      'invoice_type' =&gt; $this-&gt;input-&gt;post('type'),
      'reference_no' =&gt; $this-&gt;input-&gt;post('ref'),
      'des_title' =&gt; $this-&gt;input-&gt;post('title'),
  
  
       );
  
      $data2 = array(
          'reference_no' =&gt; $this-&gt;input-&gt;post('ref'),
          'description' =&gt; $this-&gt;input-&gt;post('des'),
          ); 
   $this-&gt;sample_model-&gt;insert_entry($data1, $data2);
  </code></pre>
  
  <p>This My MOdel :</p>
  
  <pre><code>function insert_entry($data1, $data2) {
  
      $this-&gt;db-&gt;insert('myinvoice', $data1);
      $this-&gt;db-&gt;insert('invoice_description', $data2);
  }
  </code></pre>
  
  <p>What i want is insert mutiple descriptions for one reference number. myinvoice is parent table and invoice_description is child table when i insert single data its works perfectly but i want insert multiple descriptions</p>