Codeigniter 代码点火器页码显示不正确

Codeigniter 代码点火器页码显示不正确,codeigniter,pagination,Codeigniter,Pagination,结果页中未正确显示Codeigniter分页编号 请帮帮我 /控制器页代码/ 我认为这是一个问题 $config[“total_rows”] = $this->search_product_model->record_count(); 为此,您没有传递搜索键,这样它将计算它包含的所有数据。如果您根据搜索键获得记录计数,那么就可以了。如下所示 $config[“total_rows”] = $this->search_product_model->record_c

结果页中未正确显示Codeigniter分页编号

请帮帮我

/控制器页代码/


我认为这是一个问题

  $config[“total_rows”] = $this->search_product_model->record_count();
为此,您没有传递搜索键,这样它将计算它包含的所有数据。如果您根据搜索键获得记录计数,那么就可以了。如下所示

  $config[“total_rows”] = $this->search_product_model->record_count('//search parameters');
在您的模型中:

Public function record_count($search_params)
{
   $this->db->where('product',$search_params);
   return $this->db->count_all(“products”);
}
 public function get_search($limit, $page)
{
 //Add this...???
  $this->db->limit($limit, $page);  //or try $this->db->limit($page,$limit)

}
您可以根据需要进行修改,如将“颜色”、“类型”传递给record_count()函数,并基于此,建议获取“count_all”。我希望它对您有用

 function search_all()
 {               
   $config[‘base_url’] =  base_url(’product_search/search_all’);
   $config[“total_rows”] = $this->search_product_model->record_count();//2 in your case
   $config[“per_page”] = 8;
   $config[“uri_segment”] = 3;

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

$page = ($this->uri->segment(3)) ? $this->uri->segment(3) : 0;
$data[“results”] = $this->search_product_model->
get_search($config[“per_page”], $page);
$data[“links”] = $this->pagination->create_links();

//$this->load->view(“example1”, $data);
$this->load->view(‘asd’, $data);
}
在您的模型中:

Public function record_count($search_params)
{
   $this->db->where('product',$search_params);
   return $this->db->count_all(“products”);
}
 public function get_search($limit, $page)
{
 //Add this...???
  $this->db->limit($limit, $page);  //or try $this->db->limit($page,$limit)

}

将record_count()函数中的搜索键作为参数//得到2 na


然后,将提供给记录的相同键放置在搜索参数的位置_count()

请显示处理当前问题的控制器和视图。根据您当前的解释,我们无法帮助您。您必须发布一些代码。我们看不见你的脑袋/*模型页面代码*/函数get_search($limit,$start){$match3=$this->input->post($search3');$this->db->like($color',$match3);$match2=$this->input->post($search2');$this->like($type',$match2);$query=$this->db->limit db->limit limit$limit,$start)->get($products);return$query->result();}公共函数记录计数(){return$this->db->count_all(“产品”)}/*查看页面代码*/foreach($results as$data){?>$config[“total_rows”]=$this->搜索产品模型->记录计数(“”);函数记录计数($search\u params){$this->db->where('products',$search_params);在我的搜索显示的产品1记录中返回$this->db->count_all('products”)}..但是显示的页码(1,2,3)…我将每个页面显示8条记录的条件放入..如何控制页码?这意味着您希望显示(1,2,3,4…)像那样…?(1,2)我希望搜索记录显示在8条记录上方,需要像那样分页(1,2)。否则在搜索结果页中显示在8条记录下方,分页编号不需要显示。公共函数get_search($config[“per_page”],$page)解析错误:语法错误,意外'[”,应为“)”搜索\产品\模型::记录\计数()未定义变量:搜索缺少参数1_params@murai...you你不应该复制我给你的所有东西。只要根据你的需要做一些简单的编辑就可以了。