我对codeigniter的分页有问题,与我在较旧的codeigniter版本中所做的技术相同,但效果很好,但在最新版本(3.1.9)中却不行。第一个首页可以很好地获取数据,但是当我单击第2、3或4页时,它仍显示第一个前行数据。
这是我的控制人:
$total_rows = $this->estate_model->estate_count();
$config = pagination_configuration(base_url("real_estate"), $total_rows, 10, 3, 5, true);
$this->pagination->initialize($config);
$page = ($this->uri->segment(2)) ? $this->uri->segment(3) : 0;
$page_num = $page-1;
$page_num = ($page_num<0)?'0':$page_num;
$page = $page_num*$config["per_page"];
$data["links"] = $this->pagination->create_links();
$obj_result = $this->estate_model->get_all_active_estate($config["per_page"], $page);
型号:
public function get_all_active_estate($limit, $start)
{
$this->db->select('*');
$this->db->from('estate');
$this->db->where('status', 'active');
$this->db->limit($limit, $start);
$Q = $this->db->get();
if ($Q->num_rows() > 0) {
$return = $Q->result();
} else {
$return = 0;
}
$Q->free_result();
return $return;
}
请帮助。.谢谢
答案 0 :(得分:0)
尝试 $ page =($ this-> uri-> segment(3))吗? $ this-> uri-> segment(3):0;
代替
$page = ($this->uri->segment(2)) ? $this->uri->segment(3) : 0;