答案 0 :(得分:2)
分页是代码点火器中的库之一...
git push
您可以从此处获取参考... https://www.codeigniter.com/userguide3/libraries/pagination.html
答案 1 :(得分:0)
您还可以手动管理分页,有时这可能会更轻松,具体取决于您的操作:假设您希望每页批量处理100个结果,将page_number参数传递给控制器,然后
$results_limit = 100;
$offset = 0;
if (isset($_GET['page_number']))
$offset = ($_GET['page_number']-1) * $results_limit;
$this->db->select('*');
$this->db->from('sltax_tax_name');
$this->db->order_by("t_id", "desc");
$this->db->limit($offset, $results_limit);
$query = $this->db->get();
// grab your results...
答案 2 :(得分:0)
使用CodeIgniter中的Pagination类要比手动操作容易。
https://www.codeigniter.com/userguide3/libraries/pagination.html
在控制器中
$this->load->library('pagination');
$config['base_url'] = 'http://example.com/index.php/test/page/';
$config['total_rows'] = 200;
$config['per_page'] = 20;
$this->pagination->initialize($config);
在视图中
echo $this->pagination->create_links();