2017-10-14 68 views
0

任何人都可以請幫助我嗎?我想分頁我的表格。所有鏈接都在工作,但是這些項目在其他頁面上重複。我在這裏嘗試了類似的問題,但沒有任何工作。codeigniter分頁:鏈接正在工作,但記錄在其他頁面上重複

function index($type="deposit", $limit_from=0) 
{ 
    $limit_from = ($this->uri->segment(4)) ? $this->uri->segment(4) : 0; 
    $total_records = $this->Expense->get_total_rows($type); 
    $data['controller_name'] = $this->get_controller_name(); 

    $lines_per_page = 3; 
    $data[$type.'s'] = $this->Expense->get_records($lines_per_page, $limit_from, $type); 

    $config['base_url'] = base_url('index.php/expenses/index/'.$type); 
    $config['total_rows'] = $total_records; 
    $config['per_page'] = 3; 
    $config["uri_segment"] = 4; 
    // $choice = $total_records/$config['per_page']; 
    // $config['num_links'] = round($choice); 
    $config['use_page_numbers'] = TRUE; 
    $config['first_url'] = base_url('index.php/expenses/index/'.$type.'/1'); 

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

    $this->load->view('expenses/'.$type, $data); 
    $this->_remove_duplicate_cookies(); 
} 
+1

你好, 請參考此鏈接,也許你會得到幫助! https://www.formget.com/pagination-in-codeigniter/ – Afzal

回答

0

謝謝大家。我得到它的工作:以下是我終於做的,它的工作很棒!

function index($type="deposit", $sort_by='deposit_date', $sort_order='asc', $page_limit=0) 

{ 
    $data['controller_name'] = $this->get_controller_name(); 
    $config = array(); 
    $config['base_url'] = site_url("expenses/index/$type/$sort_by/$sort_order"); 
    $config['total_rows'] = $this->Expense->get_total_rows($type); 
    $config['per_page'] = 4; 
    $config["uri_segment"] = 6; 

    $data['num_rows'] = $config['total_rows']; 
    $data['type'] = $type; 


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

    $page = ($this->uri->segment(6)) ? $this->uri->segment(6) : 0; 

    $data[$type.'s'] = $this->Expense->get_records($config["per_page"], $page, $type, $sort_by, $sort_order); 
    $data["links"] = $this->pagination->create_links(); 

    $data['headers'] = $this->Expense->table_headers($type); 
    $data['sort_by'] = $sort_by; 
    $data['sort_order'] = $sort_order; 


    $this->load->view('expenses/'.$type, $data); 
    $this->_remove_duplicate_cookies(); 
} 
相關問題