【发布时间】:2014-10-21 10:00:30
【问题描述】:
我正在使用 Codeigniter 2.2,我尝试构建分页询问 Codeigniter 指南,当我用作下面的 url 时,它对我来说非常有效
$pages_num: is the amount of pages for view.
http://localhost/Codeigniter2.1.4/public_html/page/$pages_num
但是当我为 url 添加一个参数时出现错误 作为下面的代码,我尝试在 3 周前找到它但我没有解决方案请 注:数字 2 是 id 类别,数字 4 是分页视图量
http://localhost/Codeigniter2.1.4/public_html/cat/2/4
这是我在控制器中的代码
$this->load->model('frontend/categories_m');
$count = $this->db->count_all_results('job');
$perpage = 2;
if ($count > $perpage) {
$this->load->library('pagination');
$config['base_url'] = site_url('cat/2');
$config['total_rows'] = $count;
$config['per_page'] = $perpage;
$config['uri_segment'] = 3;
$this->pagination->initialize($config);
$this->data['pagination'] = $this->pagination->create_links();
$offset = $this->uri->segment(3);
} else {
$this->data['pagination'] = '';
$offset = 0;
}
$this->db->limit($perpage, $offset);
$this->data['job_cat'] = $this->job_m->get_job();
$this->data['subview'] = 'cat';
$this->load->view('_main_layout', $this->data);
这里供大家参考:
<?PHP if ($pagination): ?>
<section class="pagination">
<?PHP echo $pagination; ?>
</section>
<?PHP endif; ?>
请帮忙
抱歉,这里不能发图片
【问题讨论】:
标签: php ajax codeigniter pagination