如何在codeigniter中将动态表中的多个数据插入mysql

Can someone help me, please?
I try to save a value from multiple dynamic boxes from bootstrap into MySQL?

I have tried much suggestion but only the first row inserted, no other data from the added table. seem like the loop isn't working.

this is one of my code to insert the data.

my view :

<div class="container">
   <div class="row clearfix">
      <div class="col-md-12 column">
         <table class="table table-bordered table-hover" 
            id="tab_logic">
            <thead>
               <tr >
                  <th class="text-center">
                     Bilangan
                  </th>
                  <th class="text-center">
                     Nama
                  </th>
                  <th class="text-center">
                     Tarikh Lahir
                  </th>
                  <th class="text-center">
                     Tempat Lahir
                  </th>
                  <th class="text-center">
                     Warganegara
                  </th>
               </tr>
            </thead>
            <tbody>
               <tr id='addr0'>
                  <td>
                     1
                  </td>
                  <td>
                     <input type="text" name='nama_siblings[]'  
                        placeholder='Nama' class="form-control"/>
                  </td>
                  <td>
                     <input type="text" name='tarikh_lahir_siblings[]' 
                        placeholder='Tarikh Lahir' class="form-control"/>
                  </td>
                  <td>
                     <input type="text" name='tempat_lahir_siblings[]' 
                        placeholder='Tempat Lahir' class="form-control"/>
                  </td>
                  <td>
                     <input type="text" name='warganegara_siblings[]' 
                        placeholder='Warganegara' class="form-control"/>
                  </td>
               </tr>
               <tr id='addr1'></tr>
            </tbody>
         </table>
      </div>
   </div>
   <tr>
      <td height="100"></td>
   </tr>
   <a id="add_row" class="btn btn-default pull-left">Tambah</a><a id='delete_row' class="pull-right btn btn-default">Buang</a>
</div>
<SCRIPT>
   $(document).ready(function(){
      var i=1;
      $("#add_row").click(function(){
      $('#addr'+i).html("<td>"+ (i+1) +"</td><td><input name='nama_siblings"+i+"' type='text' placeholder='Nama' class='form-control input-md'  /> </td><td><input  name='tarikh_lahir_siblings"+i+"' type='text' placeholder='Tarikh lahir'  class='form-control input-md'></td><td><input  name='tempat_lahir_siblings"+i+"' type='text' placeholder='Tempat Lahir'  class='form-control input-md'></td><td><input  name='warganegara_siblings"+i+"' type='text' placeholder='Warganegara'  class='form-control input-md'></td>");

      $('#tab_logic').append('<tr id="addr'+(i+1)+'"></tr>');
      i++; 
     });
     $("#delete_row").click(function(){
         if(i>1){
         $("#addr"+(i-1)).html('');
         i--;
         }
     });
});

</script>

My controller :

$xsscleanibu_id = $this->security->xss_clean($this->input->post('ibu_id')); 
$xsscleannama_siblings = $this->security->xss_clean($this->input->post('nama_siblings'));   
$xsscleantarikh_lahir_siblings = $this->security->xss_clean($this->input->post('tarikh_lahir_siblings'));   
$xsscleantempat_lahir_siblings = $this->security->xss_clean($this->input->post('tempat_lahir_siblings'));   
$xsscleanwarganegara_siblings = $this->security->xss_clean($this->input->post('warganegara_siblings')); 

foreach($rows as $row){

   $nama_siblings = $nama_siblings[$index];
   $ibu_id = $ibu_id[$index];
   $tarikh_lahir_siblings = $tarikh_lahir_siblings[$index];
   $tempat_lahir_siblings = $tempat_lahir_siblings[$index];
   $warganegara_siblings = $warganegara_siblings[$index];

   $data2 = array(
   'ibu_id'=>$xsscleanibu_id,
   'nama_siblings'=>$row,
   'tarikh_lahir_siblings'=>$xsscleantarikh_lahir_siblings,
   'tempat_lahir_siblings'=>$xsscleantempat_lahir_siblings,
   'warganegara_siblings'=>$xsscleanwarganegara_siblings
   );
   $this->inq_model_dev->insertMonday($data2);
}

   if($row)
   { 
      echo "<script>alert('Data Berjaya disimpan');
window.location = '".base_url('index.php/efast/dashboard_efast')."';</script>";
    }
    else 
    { 
      echo "<script>alert-danger('Data gagal disimpan');window.location = '".base_url('index.php/efast/pendaftaran')."';</script>";
    }

My Model :

function insertMonday($data2){

     foreach($data as $data2){
        $this->db->insert('data_anak', $data2);
     }
}

When you insert multiple data use insert_batch codeigniter default function.

 function insertMonday($data2){

        foreach($data as $data2){
            $this->db->insert_batch('data_anak', $data2);
        }

    }