【发布时间】:2016-10-27 08:24:37
【问题描述】:
我是 Codeigniter 的新手,我正在尝试使用 pagination。我的问题出乎意料,因为我的分页代码运行良好,除了 URI 段总是作为布尔值返回。我的代码是:
/* pagination */
$this->load->library('pagination');
$destination = $data['destination'];
$config = array();
$config["base_url"] = SEARCHHOTELS.$this->uri->segment(3);
$total_row = $this->db->get('hotel')->num_rows();
$config["total_rows"] = $total_row;
$config["per_page"] = 30;
$config['use_page_numbers'] = TRUE;
$config['num_links'] = $total_row;
$config['cur_tag_open'] = '<a class="active">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
$str_links = $this->pagination->create_links();
$this->db->select('*');
if(!empty($data['destination'])){
$destination = $data['destination'];
$this->db->like('name',$destination);
$this->db->or_like('regionName',$destination);
}
$hSearch['records'] = $this->db->get('hotel',$config['per_page'],$this->uri->segment(3))->result_array();
$hSearch["links"] = explode(' ',$str_links);
/* paginationEnd */
SEARCHHOTELS 常量在哪里
define('SEARCHHOTELS', SITE_URL.'search/hotels/');
在我的代码中:$this->uri->segment(3) 总是返回布尔值。
当我点击我的分页时,URL 值从:
http://localhost/holidays/search/hotels/
到:
http://localhost/holidays/search/hotels/1 (or 2,3,4)
URI 段没有在我的$this->db-get 查询中设置偏移值。 #
任何帮助将不胜感激。
【问题讨论】:
标签: php codeigniter pagination