emprit

input dinamis

Dec 8th, 2012
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.33 KB | None | 0 0
  1. ----------------Controller---------------
  2. function administrasi_tambah() {
  3.         if($this->session->userdata('sudah_login_pelamar')){
  4.                         $user=$this->session->userdata('username');
  5.             $config['upload_path'] = './kelengkapan_dokumen/';
  6.             $config['allowed_types'] = 'jpg|pdf';
  7.  
  8.             $this->load->library('upload', $config);
  9.  
  10.                 if ( ! $this->upload->do_upload()){
  11.                     $array = array( 'content' => $this->load->view('akun_pelamar/gagal','',true) );
  12.                $this->load->view('akun_pelamar/menu', $array);
  13.                 }else{
  14.                     $reg['query'] = $this->pelamar_model->tambahkelengkapan();
  15.                         if($reg['query']) {
  16.                             $array = array( 'content' => $this->load->view('akun_pelamar/sukses','',true) );
  17.                             $this->load->view('akun_pelamar/menu', $array);
  18.                         }
  19.                 }
  20.         }else {
  21.             redirect('index/index');
  22.             }
  23.         }  
  24.  
  25. ---------Model----------------
  26. function tambahkelengkapan() {
  27.         $no=$this->input->post('no_urut');     
  28.        
  29.         $img = $this->upload->data();
  30.         $file_name = "GE".$no."_".$img['file_name'];
  31.         $path = './kelengkapan_dokumen/';
  32.       rename($path.$img['file_name'], $path.$file_name);            
  33.              
  34.       $query1  = $this->db->query("SELECT * FROM form WHERE type != '0'");
  35.       $result = $query1->result();
  36.      
  37.       $i=0;
  38.       $len=count($result);
  39.       $emprit = "$";
  40.       $emprit .= "data = array(";
  41.       foreach($result as $row){
  42.         if($i == $len - 1) {
  43.             if($row->type == 'file'){
  44.                 $emprit .= "'".$row->nama."' => ";
  45.                 $emprit .= "$";
  46.                 $emprit .= "file_name";
  47.                 }else{
  48.                    $emprit .= "'".$row->nama."' => ";
  49.                    $emprit .= "$";
  50.                    $emprit .= "this";
  51.                    $emprit .= "->input->post('".$row->nama."')";
  52.                         }                
  53.                 }else{
  54.                if($row->type == 'file'){    
  55.                $emprit .= "'".$row->nama."' => ";
  56.                 $emprit .= "$";
  57.                 $emprit .= "file_name,";
  58.                 }else{
  59.                     $emprit .= "'".$row->nama."'=> ";
  60.                      $emprit .= "$";
  61.                    $emprit .= "this";
  62.                    $emprit .= "->input->post('".$row->nama."'),";
  63.                 }
  64.                 }
  65.                
  66.                 $i++;
  67.       }
  68.            $emprit .= ");";
  69.        
  70.         echo $emprit;
  71.         $query = $this->db->insert('penilaian',$data);
  72.         return $query;
  73.     }
Advertisement
Add Comment
Please, Sign In to add comment