novalsmith

prosessimpan.php

Nov 20th, 2016
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.66 KB | None | 0 0
  1.  public function create_action()
  2.  
  3.     {
  4.  
  5.     $mks = $this->input->post('mk');
  6.     $result = array();
  7.  
  8.     foreach($mks AS $key => $val)
  9.     {
  10.  
  11.  
  12.  
  13.         $this->db->where(array(
  14.        
  15.        "id_mk_tawaran"        => $_POST['mk'][$key],
  16.                          
  17.                                       )
  18.  
  19.             );
  20.          $cek = $this->db->get("entry");
  21.     }
  22.        
  23.      
  24.  
  25. if($cek->num_rows() > 0 )
  26.  
  27.     {
  28.  
  29.  $this->session->set_flashdata('message',
  30.                 '<div class="alert alert-danger">
  31. <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  32.        <strong>Maaf !</strong> Data yang Maksudkan sudah Ada.  '.$_POST['mk'][$key].'  
  33.  
  34.                 </div>');      
  35.  
  36.      redirect(site_url('entry'));
  37.  
  38. }else
  39. {
  40.  
  41.  
  42.     $mks = $this->input->post('mk');
  43.     $result = array();
  44.     foreach($mks AS $key => $val){
  45.      $result[] = array(
  46.       "id_mahasiswa"  => 7,
  47.       "waktu_entry"  => '2016',
  48.          "semester_aktif"  => 2,
  49.             "validasi"  => 'BELUM',
  50.                "id_mk_tawaran"  => $_POST['mk'][$key]
  51.      );
  52.     }            
  53.    
  54.     $test= $this->db->insert_batch('entry', $result); // fungsi dari codeigniter untuk menyimpan multi array
  55.    
  56.     if($test){
  57.  $this->session->set_flashdata('message',
  58.                 '<div class="alert alert-success">
  59. <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
  60.        <strong>Success Saved!</strong> Your Data is Successful.
  61.  
  62.                 </div>');          
  63.                   redirect(site_url('entry'));
  64.       }else{
  65.      echo "gagal di input";
  66.     }
  67.  
  68.  
  69.         }
  70.    
  71.    
  72.  
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment