Advertisement
sebuahhobi

input 2 tabel

Jul 31st, 2018
188
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.61 KB | None | 0 0
  1. public function create_action()
  2.     {
  3.         $this->_rules();
  4.        
  5.         if ($this->form_validation->run() == FALSE) {
  6.             $this->create();
  7.         }
  8.         else {
  9.             $user=$this->ion_auth->user()->row();
  10.             $data = array(
  11.         'nama'     => $this->input->post('nama',TRUE),
  12.         'npm'      => $this->input->post('npm',TRUE),
  13.         'fakultas' => $this->input->post('fakultas',TRUE),
  14.         'jurusan'  => $this->input->post('jurusan',TRUE),
  15.         'semester' => $this->input->post('semester',TRUE),
  16.         'kamar'    => $this->input->post('kamar',TRUE),
  17.         //'operator' => $this->input->post('operator',TRUE),
  18.                 'operator' =>$user->first_name.' '.$user->last_name,
  19.         'noHP'     => $this->input->post('noHP',TRUE),
  20.         );
  21.            
  22.             $ambil_id_mhs   = $this->db->get_where('daftar_mhs',array('npm'=>$this->input->post('npm',TRUE)));
  23.             $ambil_id_kamar = $this->db->get_where('kamar',array('kamar'=>$this->input->post('kamar',TRUE)));
  24.             foreach ($ambil_id_mhs->result() as $main){
  25.                 foreach ($ambil_id_kamar->result() as $mhs){
  26.                     $kamar_id=$mhs->id;
  27.                     $mhs_id=$main->id;
  28.  
  29.                 }
  30.             }
  31.            
  32.             $data_kamar=array(
  33.                 'id_mhs'   => $mhs_id,  
  34.                 'id_kamar' => $kamar_id
  35.             );
  36.            
  37.             $this->admin_model->insert($data);
  38.              $this->mhs_kamar_model->insert($data_kamar);
  39.             $this->session->set_flashdata('message', 'Create Record Success');
  40.             redirect(site_url('admin_mahad_2014/'));
  41.         }
  42.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement