2013-04-15 108 views
0

我用笨分頁類進行分頁我的記錄,下面你可以看到我的代碼分頁鏈接不是笨分頁顯示

$data['success'] = ""; 
    $data['error'] = ""; 
    $data['offset'] = 0; 

    $this->load->library('pagination'); 
    $per_page = 4; 
    $total = $this->m_workshop->totalworkshoppay(); 
    $baseUrl = site_url('sitemanager/workshop/workshopayment'); 
    $data['query'] = $this->m_workshop->getallwpay($per_page, (int) $this->uri->segment(4));  
    $confignew['base_url'] = $baseUrl; 
    $confignew['total_rows'] = $total; 
    $confignew['per_page'] = $per_page; 
    $confignew['uri_segment'] = '4'; 
    $this->pagination->initialize($confignew); 


    $data['offset'] = (int) $this->uri->segment(4); 
    $this->load->view('sitemanager/workshop/viewallworkshoppay',$data); 

我用<?php echo $this->pagination->create_links(); ?>代碼在我看來,頁面顯示分頁links.But的分頁鏈接不顯示在瀏覽器中。當我打印$data['query']時,記錄根據$per_page變化限制。

+0

如果你有數據記錄不到'per_page',該'create_links'將不會出現。 – MSI

回答

1

首先在您的控制器中創建鏈接。你還必須確保你抓取足夠的記錄來建立鏈接。首次設置時,我通常會將每頁設置爲1,以確保其正常工作。

控制器:

$data['success'] = ""; 
    $data['error'] = ""; 
    $data['offset'] = 0; 

    $this->load->library('pagination'); 
    $per_page = 4; 
    $total = $this->m_workshop->totalworkshoppay(); 
    $baseUrl = site_url('sitemanager/workshop/workshopayment'); 
    $data['query'] = $this->m_workshop->getallwpay($per_page, (int) $this->uri->segment(4));  
    $confignew['base_url'] = $baseUrl; 
    $confignew['total_rows'] = $total; 
    $confignew['per_page'] = $per_page; 
    $confignew['uri_segment'] = '4'; 
    $this->pagination->initialize($confignew); 
    $data['pages'] = $this->pagination->create_links(); 


    $data['offset'] = (int) $this->uri->segment(4); 
    $this->load->view('sitemanager/workshop/viewallworkshoppay',$data); 

查看:

echo $pages; 
+0

謝謝,我發現$ total變量的問題值是0,返回值有問題 –