title: How can i insert multiple arrays into mysql database using codeginiter?
body: <p>What i want is, i have a uniq id call <strong>num</strong> i want insert <strong>mutiple description</strong> for that unique <strong>num</strong>. i have a form to add fileds <strong>dynamically</strong> so i can add fields as much i want. when i try to insert one row data its works perfectly when i try to insert more than one row data it doesn't work. </p>
  
  <p><strong>My View page :</strong></p>
  
  <pre><code>&lt;form name="codexworld_frm" action="" method="post"&gt;
  
  &lt;div class="field_wrapper"&gt;
  &lt;input type="text" name="num" value=""/&gt;&lt;br /&gt;
  
  &lt;input type="text" name="description[]" value=""/&gt;&lt;input type="text" name="voucher_no[]" value=""/&gt;&lt;input type="text" name="price[]" value=""/&gt;
          &lt;a href="javascript:void(0);" class="add_button" title="Add field"&gt;&lt;img src="&lt;?php echo base_url('images/add-icon.png'); ?&gt;"/&gt;&lt;/a&gt;
  
  &lt;/div&gt;
  &lt;input type="submit" name="submit" value="SUBMIT"/&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>My Controller :</strong></p>
  
  <pre><code>$data = array(
                  'no' =&gt; $this-&gt;input-&gt;post('num'),
                  'descriptions' =&gt; $this-&gt;input-&gt;post('description'),
                  'voucher' =&gt; $this-&gt;input-&gt;post('voucher_no'),
                  'des_price' =&gt; $this-&gt;input-&gt;post('price'),
              );
  
              $this-&gt;multi_model-&gt;form_insert($data);
  
              $data['message'] = 'Data Inserted Successfully';
              //Loading View
              $this-&gt;load-&gt;view('multi_view', $data);
  </code></pre>
  
  <p><strong>My Model:</strong></p>
  
  <pre><code>function form_insert($data){
  
      $this-&gt;db-&gt;insert('tbl_description', $data);
      }
  </code></pre>
  
  <p><strong><em>if i use foreache loop into my model i think it will work but i how do i use ?</em></strong></p>
  
  <p><strong>When i use print_r()</strong> function this is out put</p>
  
  <pre><code>    1001
  Array
      (
          [0] =&gt; description1
          [1] =&gt; description2
          [2] =&gt; description3
      )
      Array
      (
          [0] =&gt; voucher 1
          [1] =&gt; voucher 2
          [2] =&gt; voucher 3
      )
      Array
      (
          [0] =&gt; 100
          [1] =&gt; 200
          [2] =&gt; 300
      )
  </code></pre>