4

我是第一次使用 codeigniter 的分页类。其他一切工作正常,但无论我去哪个页面,活动链接始终是 [1] 并且它不会改变。下一个按钮也总是链接到第一页。想不通为什么!请帮忙 !

控制器

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

1 回答 1

6

听起来 CI 无法弄清楚你应该在哪个页面上。尝试为数组添加uri_segment或。cur_page$config

应该告诉 CI url的uri_segment哪一部分包含当前页码,从您的示例代码中它似乎是4(来自查询),而 CI 的默认值为 3。

于 2012-08-25T13:27:24.127 回答