2017-10-14 3 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(); 
}