CodeIgniter分页不起作用

时间:2012-07-30 19:12:05

标签: codeigniter pagination

我设置了CodeIgniter分页的属性,但是我收到了错误。

1 2 3 4 5 >

我的分页工作在第2-5页,但第1页除外。我没有意识到它为什么会发生。这是我的控制器功能,其中控制器名称为c_forum

function show_posts_by_chapter($id_chapter=false) {
    if($id_chapter==false)
        show_404();


    $config = array();
    $config["base_url"] = base_url() . "index.php/c_forum/show_posts_by_chapter/" . $id_chapter.'/';
    $config['total_rows'] = $this->m_forum->num_rows_by_chapter($id_chapter);

    $config['per_page'] = 2;
    $configp['uri_segment'] = 4;

    $choice = $config["total_rows"] / $config["per_page"];
    $config["num_links"] = round($choice);
    $this->pagination->initialize($config);
    $page = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0;

    $data['chapter_id'] = $id_chapter;
    $data['allowed'] = $this->_get_level();
    $data['count_rows'] = $config['total_rows'];


    $data['posts_all'] = $this->m_forum->get_posts_by_chapter($config['per_page'], $page, $id_chapter);
    $data['links'] = $this->pagination->create_links();
    $this->load->view('forum/show_posts', $data);
}

查看很简单:

 `<?php echo $links; ?>`

得到了回答:我使用了$configp['uri_segment'] = 4;,它应该是$config['uri_segment'] = 4;

1 个答案:

答案 0 :(得分:0)

$ configp ['uri_segment'] = 4;
这应该是
  $ config ['uri_segment'] = 4;