使用where子句时Codeigniter分页问题

Codeigniter pagination with the passing parameter to where clause links not working

Here is my Model

public function record_count($category) {

  return $this->db->where('sub_category_name',$category)->count_all_results("categories_item");

}

 public function fetch_departments($category,$limit, $start) {

  $this->db->limit($limit, $start);

 $query=$this->db->where('sub_category_name',$category)->get("categories_item");

 if ($query->num_rows() > 0) 
     {
         foreach ($query->result() as $row) 
            { 
                $data[] = $row;
            }
          return $data;
       }
    return false;
   }
//Here is Controller
public function categories_item()
    {
        $this->load->database();
        $this->load->library('pagination');
        $this->load->model('Home_model');
        $config = array();
        $config["base_url"] = base_url() . "Home/categories_item";
        $category=$this->uri->segment(3);
        $this->db->where('sub_category_name',$category);        
       $config['total_rows'] =  $this->db->get('categories_item')->num_rows();
       $config['use_page_numbers'] = TRUE;
       $config["per_page"] = 1;
       $config["uri_segment"] = 3;
       $this->pagination->initialize($config);
       $page = ($this->uri->segment(3)) ? ($this->uri->segment(3)) : 0;
       $data["link"] = $this->pagination->create_links();
      if( !$data["results"] = $this->Home_model->fetch_departments($category,$config["per_page"], $page))
       {
         error_reporting(1);
       }
     else
       {
          $this->load->view("category_item_list",$data);
       }
    }
dongmeiba6151
dongmeiba6151 通过jquerypagination.js解决了它。但是如何在codeigniter上解决它
一年多之前 回复
dongxing8766
dongxing8766 Dhoke,同样的结果,没有工作
一年多之前 回复
duanli3277
duanli3277 不要在controller.call中添加模型代码,从模型中查询并重试。
一年多之前 回复
douyuanqia665858
douyuanqia665858 不知道,也许是它的抵消问题
一年多之前 回复
Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问