0

我首先使用 Codeigniter 分页类。

控制器 :-

public function index($issue_id = 0)
    {
        if(empty($issue_id))
        {
            $config = array(
               array(
                     'field'   => 'seltype',
                     'label'   => 'Type of issue',
                     'rules'   => 'trim'
                  ),
               array(
                     'field'   => 'txttitle',
                     'label'   => 'Title',
                     'rules'   => 'trim|required'
                  ),
            );
            $this->form_validation->set_rules($config);


            $this->load->library('pagination');

            $config['base_url'] = site_url()."/new_issues";
            $config['total_rows'] = $this->all_model->total_new_level_records(1);

            $offset = $this->uri->segment(3);
            $config['per_page'] = 9; 

            $config['uri_segment'] = 3;
            $config['use_page_numbers'] = TRUE;

            $this->pagination->initialize($config); 

            $data['level_one'] = $this->all_model->new_level_issues(1,$config["per_page"], $config['uri_segment']);

            $data["links"] = $this->pagination->create_links();

            $this->load->view("new_issues_page", $data);
        }
}

我从 db 获得了总共 33 行,而且我可以在我的视图页面中看到分页,显示 1,2,3 最后。但是当我点击 2 链接时,它没有显示任何结果。

编辑:-单击 2 页时得到的 URL 是:- http://www.example.com/new_issues/2

我也尝试打印 :-$offset = $this->uri->segment(3);但它没有显示任何内容。

4

2 回答 2

0

$this->load->model('all_model')在调用模型函数之前加载模型。

尝试

$this->load->model('all_model');

        $config = array();
        $config['base_url'] = site_url("controller/method");
        $config['total_rows'] = $this->db->get_where('table name',array('where condition'))-> num_rows();
        $config['per_page'] = 9;
        $config['uri_segment'] = 5;
        $this->pagination->initialize($config);
        $data['pagination'] = $this->pagination->create_links();
于 2013-05-31T07:36:41.250 回答
0

尝试替换like,应该是url的第三段

$config['uri_segment'] = 3;

你的 base_url 应该像

$config['base_url'] = site_url()."/new_issues/index";

不是其他新功能

于 2013-05-30T09:57:00.070 回答