CodeIgniter Paging类,活动链接无法正常工作

时间:2012-08-25 11:39:17

标签: php codeigniter

我第一次使用codeigniter的分页类。其他一切都运行正常,但无论我去哪一页,活动链接始终是[1]并且它不会改变。此外,下一个按钮始终链接到第一页。 Culd没弄明白为什么!请帮忙!

控制器

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; ?>

1 个答案:

答案 0 :(得分:6)

声音就像CI无法弄清楚你应该在哪个页面上。 尝试为uri_segment数组添加cur_page$config

uri_segment应该告诉CI网址的哪个部分包含当前页码,从您的示例代码看起来是4(来自查询),而CI的默认值是3