aries_

paging

Aug 26th, 2012
90
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.09 KB | None | 0 0
  1. <-----------------controller------------------>
  2.  function cari(){
  3.         $cat = $this->input->post('pilih');
  4.    
  5.        
  6.     if ($cat == 1) {
  7.             $tgl_awal = $this->input->post('tanggal');
  8.            $tgl_akhir = $this->input->post('tanggal_2');
  9.  
  10.             $data['View_training'] = $this->VT->cari_plan_tgl($tgl_awal,$tgl_akhir);
  11.             $data['isi']='Data_view';
  12.             $this->load->view('template', $data);
  13.         }
  14.         elseif ($cat == 2){
  15.         $page=$this->uri->segment(3);
  16.     if(!$page):
  17.     $offset = 0;
  18.     else:
  19.     $offset = $page;
  20.     endif;
  21.     $data['View_training']="";
  22.     $judul = $this->input->post('materi');
  23.  
  24.            if(!empty($judul))
  25.         {
  26.  
  27.         $data['View_training'] = $this->input->post('materi');
  28.                 $this->session->set_userdata('materi',$judul);
  29.                
  30.         }
  31.         else
  32.         {
  33.         $data['View_training'] = $this->session->userdata('materi');
  34.         }
  35.     $data['View_training'] = $this->VT->cari_plan_judul($judul,5,$offset);
  36.     $tot_hal = $this->VT->tot_hal($judul);
  37.  
  38.     $config['base_url'] = base_url() . 'index.php/cuser/cari/';
  39.         $config['total_rows'] = $tot_hal->num_rows();
  40.         $config['per_page'] =5;
  41.       $config['uri_segment'] = 3;
  42.          $this->pagination->initialize($config);
  43.          $data['isi']='Data_view';
  44.          $this->load->view('template', $data);
  45.             }
  46.  
  47.         else {
  48.             redirect ("cuser/view" , "refresh");
  49.         }
  50.  
  51.     }
  52. <---------------------------------------------------->
  53. <-------------model------------------->
  54.  function cari_plan_tgl($tgl_awal,$tgl_akhir){
  55.  
  56.         return $this->db->query("select * from view_plan where TGL_MULAI between '$tgl_awal' and '$tgl_akhir'  ");
  57.  
  58.         }
  59.  
  60.     function cari_plan_judul ($judul,$batas,$offset) {
  61.  
  62.             $q = $this->db->query("select * from view_plan where NAMA_M_TRAINING like '%$judul%' LIMIT $offset,$batas");
  63.             return $q;
  64.     }
  65.                 function tot_hal($kata)
  66.     {
  67.         $q = $this->db->query("select * from view_plan where NAMA_M_TRAINING like '%$kata%'");
  68.         return $q;
  69.     }
  70. <--------------------------------------->
Advertisement
Add Comment
Please, Sign In to add comment