2012-08-25 58 views
4

我第一次使用codeigniter的分頁類。其他的一切工作正常,但無論我要去哪個頁面,活動鏈接始終是[1],並且不會更改。另外,下一個按鈕始終鏈接到第一頁。 Culdn't找出原因!請幫忙 !CodeIgniter尋呼類,活動鏈接不工作

控制器

public function unverified_images() 
{   
    $data['title'] = 'Choose from the below Images to verify them >>'; 
    $data['total_rows'] = $this->admin_model->all_unverified_images(); 

    $config['base_url'] = base_url().'index.php/admin/admin/unverified_images'; 
    $config['total_rows'] = $data['total_rows']->num_rows(); 
    $config['per_page'] = 1; 
    $config['num_links'] = 8; 
    $config['full_tag_open'] = '<div class="pagination">'; 
    $config['full_tag_close'] = '</div>'; 

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

    $data['query'] = $this->db->where('image_status', 0) 
        ->get('tbl_img', $config['per_page'], $this->uri->segment(4)); 
    $data['links']=$this->pagination->create_links();  
    $this->load->view('admin/image_verify', $data); 
} 

public function verify_image() 
{ 
    $data['title'] = 'Choose from the below Images to verify them >>'; 
    $data['msg'] = $this->admin_model->verify_image(); 
    $data['query'] = $this->admin_model->all_unverified_images(); 
    redirect('admin/admin/unverified_images'); 
} 

型號

function all_unverified_images() 
{ 
    $this->db->where('image_status', 0); 
    $query = $this->db->get('tbl_img'); 
    return $query; 
} 

查看

<?php echo $links; ?> 

回答

6

像CI聲音不能找出你認爲哪一頁上。 嘗試爲$config陣列添加uri_segmentcur_page

uri_segment應該告訴CI什麼URL的一部分保存當前頁面數,從您的示例代碼,它似乎是4(從查詢),而CI的缺省值是3

+0

問題解決了,非常感謝@ complex857 –