2013-05-28 52 views
0

我正在嘗試使用codeigniter實現分頁。 情況如下: 我只有3文章在我的分貝,所以我設置每頁限制爲2來測試分頁。 內容是財產損失,內部第一頁我有前兩篇文章和第二篇文章。分頁鏈接編號正確生成。分頁鏈接無法在codeigniter中正常工作,

當我在第一頁上我點擊它加載第二頁與它的內容分頁link (2),但在我這個第二頁分頁鏈接不上page 1, (1)工作沒有聯繫可言,(2)會重新鏈接?

什麼是問題?

這是我的控制器方法

function pagination() 
    { 
     $this->load->library('pagination'); 
     $this->load->library('table'); 
     $this->load->model('article_m'); 

     $config['base_url'] = 'http://mysite.com/en/news/pagination'; 
     $config['total_rows'] = $this->db->get('articles')->num_rows(); 
     $config['per_page'] = 2; 
     $config['num_links'] = 20; 

     $this->pagination->initialize($config);   
     $pag = $this->db->get('articles', $config['per_page'], $this->uri->segment(4));   
     $data['records'] = $pag->result(); 

     $this->template->view('news/pagination', $data); 
    } 

回答

10

您還需要添加此爲你的配置

$config['uri_segment'] = 4; 
+0

居然有人= 4,但是你解決它。謝謝 – panjo

+0

哇只是哇..... –

+0

@ m.qayyum謝謝 – Gautam3164