2012-07-30 88 views
0

我设置了CodeIgniter分页的属性,但出现错误。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; ?>` 

GOT answe:我用$configp['uri_segment'] = 4;并且它应该是$config['uri_segment'] = 4;

+0

你是什么意思“没有下划线1”? – 2012-07-30 19:13:22

+0

我想上传一张图片,然后你可以很容易地得到它。但新的在这里。但主要的主题是,如果我打5下一个我得到2不是1。 – 2012-07-30 19:22:01

+0

这可能是'$ config [“num_links”]',如果删除它,会发生什么? – 2012-07-30 19:26:41

回答

0

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