与参数过滤器的分页冲突,下一页只是获取循环代码

时间:2019-02-14 13:09:44

标签: php codeigniter pagination

这是我控制器上的功能数据

public  function data(){
         if($this->session->userdata('username')!=''){
            $data['nama']=$this->session->userdata('username');
         }else{

            redirect(base_url().'Salesforce/login');
         }
         $data['listprov'] = $this->Model->listProv();
         $data['kota'] = $this->Model->getListKota();
         $data['prov'] = $this->Model->getListProv();
         $data['status'] = $this->Model->getListStatus();

        $jumlah_data = $this->Model->jumlah_data();
        $data['jmlhdt']=$jumlah_data;
        $config['base_url'] = base_url().'Salesforce/data';
        $config['total_rows'] = $jumlah_data;
        $config['per_page'] = 10;
        $from = $this->uri->segment(3);
        $this->pagination->initialize($config); 

         $data['data'] = $this->Model->getJoinp($config['per_page'],$from);
         $kota = -1;
         unset($_SESSION["filtprov"]);
         unset($_SESSION["filtkota"]);

         if(isset($_GET['kota'])){

            $kota = $_GET['kota'];
            // $data['data'] = $this->Model->getJoin2($kota);

            $_SESSION["filtkota"] = $kota;
            $propro = $this->Model->getid_prov($kota);
            $_SESSION["filtprov"] = $propro[0]->id_prov;

            $jumlah_dataa = $this->Model->jumlah_datak($kota);
            $data['jmlhdt']=$jumlah_dataa;

            $config['base_url'] = base_url().'Salesforce/data?prov='.$_SESSION["filtprov"].'&kota='.$_SESSION["filtkota"];
            $config['total_rows'] = $jumlah_dataa;
            $config['per_page'] = 10;
            // $config['uri_segment']=3;
             $config['page_query_string'] = TRUE;

            $froma = $this->uri->segment(3);

            $this->pagination->initialize($config); 

            $data['data'] = $this->Model->getJoin2($kota,$config['per_page'],$froma);

        }

         $this->load->view('data',$data);

这是我关于joinp的模型:

public function getJoinp($number,$offset){
      $this->db->select('sekolah.*, status.id AS id_status, status.nama_status');
      $this->db->select('sekolah.*, kota.id AS id_kota, kota.nama_kota');
      $this->db->select('kota.*, provinsi.id AS id_prov, provinsi.nama_provinsi, sekolah.id as ids');
      $this->db->join('status', 'sekolah.id_status = status.id');
      $this->db->join('kota', 'sekolah.id_kota = kota.id');
      $this->db->join('provinsi', 'kota.id_prov = provinsi.id');
      $this->db->from('sekolah');
      $this->db->limit($number,$offset);

      $query = $this->db->get()->result_array();
      return $query;
  }

我正在使用此代码获取过滤器的分页,我对不带参数的数据的正常分页效果很好

  

http://localhost/sale/Salesforce/data

但是当我在功能上使用过滤器并通过此链接获取数据

  

http://localhost/sale/Salesforce/data?prov=7&kota=26

分页不起作用,它只是更改参数页面但没有加载数据只是像建立链接一样

  

http://localhost/sale/Salesforce/data?prov=7&kota=26&per_page=20

有什么主意吗?

0 个答案:

没有答案