-3

Codeigniter 分页数字在结果页面中未正确显示,。

请帮助我。

/控制器页面代码/

  function search_all()
  {
    $this->load->view(‘prd’); 
  $config = array();
  $config[‘base_url’] =  base_url().’/product_search/search_all’;
  $config[“total_rows”] = $this->search_product_model->record_count();
    $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);
  }
4

3 回答 3

0

give search key in the record_count() function as parameters //You got 2 na.??

Then in placeof search_params put you same keys which are supplied to the record_count()

于 2012-09-06T09:11:16.493 回答
0

我认为这有问题

  $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”);
}

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

于 2012-09-06T04:50:14.050 回答
0

尝试这个

 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 get_search($limit, $page)
{
 //Add this...???
  $this->db->limit($limit, $page);  //or try $this->db->limit($page,$limit)

}
于 2012-09-06T07:21:14.230 回答