Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public function create_action()
- {
- $mks = $this->input->post('mk');
- $result = array();
- foreach($mks AS $key => $val)
- {
- $this->db->where(array(
- "id_mk_tawaran" => $_POST['mk'][$key],
- )
- );
- $cek = $this->db->get("entry");
- }
- if($cek->num_rows() > 0 )
- {
- $this->session->set_flashdata('message',
- '<div class="alert alert-danger">
- <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
- <strong>Maaf !</strong> Data yang Maksudkan sudah Ada. '.$_POST['mk'][$key].'
- </div>');
- redirect(site_url('entry'));
- }else
- {
- $mks = $this->input->post('mk');
- $result = array();
- foreach($mks AS $key => $val){
- $result[] = array(
- "id_mahasiswa" => 7,
- "waktu_entry" => '2016',
- "semester_aktif" => 2,
- "validasi" => 'BELUM',
- "id_mk_tawaran" => $_POST['mk'][$key]
- );
- }
- $test= $this->db->insert_batch('entry', $result); // fungsi dari codeigniter untuk menyimpan multi array
- if($test){
- $this->session->set_flashdata('message',
- '<div class="alert alert-success">
- <a href="#" class="close" data-dismiss="alert" aria-label="close">×</a>
- <strong>Success Saved!</strong> Your Data is Successful.
- </div>');
- redirect(site_url('entry'));
- }else{
- echo "gagal di input";
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment