Mysql 段??没有正确理解 在分页中... 这是我的代码:
$data['query']= $this->db->select('auto_id,title,image,thumb')
->get('gallery',$config['per_page']=12,$this->uri->segment(3));
其中 per_page=12
最佳答案
尝试这样使用->
function records($sort_by = 'rpd_id', $sort_order = 'asc', $offset = 0) {
$limit = 10;
$data['results'] = $this->rcbs_Model->get_all_data_from_request($limit, $offset, $sort_by, $sort_order);
$config = array();
$config['base_url'] = base_url("rcbs/records/$sort_by/$sort_order");
$config['total_rows'] = $this->rcbs_Model->count_records();
$config['per_page'] = $limit;
$config['uri_segment'] = 5;
$data['sort_by'] = $sort_by;
$data['sort_order'] = $sort_order;
$this->pagination->initialize($config);
$data['links'] = $this->pagination->create_links();
$this->load->view('booking_data', $data);
}
here $sort_by = 'rpd_id' (rpd_id)is the default table column by which data will be sorted.
"get_all_data_from_request" is the function by which you will get all data from your table using select query.
base_url("rcbs/records/$sort_by/$sort_order"); rcbs -Controller name 'records'->function name itselft
$this->rcbs_Model->count_records() count all the records from the table.
关于php - 如何在分页库codeigniter中编写Segment,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25932462/