2014-09-11 110 views
0

沒有發現我有問題使CodeIgniter的分頁當我點擊鏈接打開我得到的404頁沒有發現 我在CONTROLER代碼CodeIgnier 404錯誤頁面分頁

class Records extends CI_Controller 
{ 
    public function index() 
    { 
     $this->load->library('pagination'); 
     $config['base_url']= 'localhost/records'; 
     $config['total_rows']= $this->db->get('pages')->num_rows; 
     $config['per_page']= 2; 
     $config['num_links']= 5; 
     $this->pagination->initialize($config); 
     $data['query'] = $this->db->get('pages',$config['per_page'],$this->uri->segment(2)); 



     $this->load->view('view_header'); 
     $this->load->view('includes/nav_home'); 
     $this->load->view('view_list', $data); 
     $this->load->view('view_footer'); 

}

我想指出錯誤的URI細分,但仍然沒有結果。 ?我以正確的方式編寫代碼。我的base_url在配置文件中是空的?

鑑於我的代碼是

<?php 
echo $this->session->flashdata('item'); 
echo '<h4>Lista podataka</h4>'; 

foreach ($query->result() as $q): 

?> 
<a href="/z/update/grab/<?php echo $q->id;?>/<?php echo $q->info; ?>"><?php echo $q->info . br() . br()?></a> 
<?php 
endforeach; 

echo $this->pagination->create_links(); 
?> 

請其非常重要的

回答

1

據我瞭解您無法訪問您的下一個頁面分頁?所以,我認爲這是因爲這個$config['base_url']= 'localhost/records';

你應該把你的完整URL(包括控制器名和函數名),所以它應該是

$config['base_url']= 'localhost/records/index.php/controller_name/function';

,並在你的URI段應$this->uri->segment(3)

+0

它的問題,因爲我把分頁索引()函數,我創建單獨的功能,它的工作原理! – 2014-09-11 08:54:13

+0

你應該把正確的base_url,嘗試改變你的代碼,並告訴我,如果你仍然有錯誤 – CodeSlayer 2014-09-11 08:58:39

+0

我做了這個和它的工作功能頁面() {this-> load-> library(s) '分頁'); $ config ['base_url'] ='http:// localhost/z/records/page'; $ config ['total_rows'] = $ this-> db-> get('pages') - > num_rows; $ config ['per_page'] = 2; $ config ['num_links'] = 5; $ this-> pagination-> initialize($ config); $ this-> load-> model('Data'); ($ 3)); $ data ['query'] = $ this-> Data-> data_pagination($ config ['per_page'],$ this-> uri-> segment(3)); } – 2014-09-11 09:33:39

0

嘗試或許會改變URI段

$this->load->library('pagination'); 
    $config['base_url']= base_url().'/records/index'; 
    $config['total_rows']= $this->db->get('pages')->num_rows; 
    $config['uri_segment'] = 3; 
    $config['per_page']= 2; 
    $config['num_links']= 5; 
    $this->pagination->initialize($config); 
    $data['query'] = $this->db->get('pages',$config['per_page'],$this->uri->segment(3)); 

更多後續: - pagination in codeigniter

+0

其問題,因爲我把分頁索引()函數,我創建了單獨的功能,它的工作原理! – 2014-09-11 08:53:47

+0

不是你需要使用正確的基址的功能問題 – 2014-09-11 08:54:46

+0

是的,也許我應該把盈虧指數!這可能是錯誤 – 2014-09-11 09:38:55

0

基地址必須是

$config['base_url']= 'records/index'; 
0

基URL中必須包含被用於獲取數據的相同功能 它意味着$配置[ 'BASE_URL'] ='本地主機/項目/記錄/索引';