0

无法在 codeigniter 中创建链接分页。代码:

$config['total_rows'] = $tot_hal->num_rows();
        $config['per_page'] = $limit;
        $config['uri_segment'] = 3;
        $config['first_link'] = 'Awal';
        $config['last_link'] = 'Akhir';
        $config['next_link'] = 'Selanjutnya';
        $config['prev_link'] = 'Sebelumnya';
        $this->pagination->initialize($config);
        $bc["paginator"] =$this->pagination->create_links();

它不能链接下一个分页,pevious。可能是什么原因?

4

2 回答 2

0

请试试这个:

        $page = ($this->uri->rsegment(3)) ? $this->uri->rsegment(3) : 0;
        $user_data['total_users'] = $total_counting; // set total number of records
        $user_data['pagination'] = $this->pagination->create_links(); // set pagination
        $user_data['page_limit'] = $lim; // set limit for pagination           
        $user_data['all_users'] = $this->User_model->get_user_list($lim, $page); // Function call from model      

        $this->template->load('template', 'users/list_user',$user_data); 

在 User_model.php 文件中

 public function get_user_list($limit=0,$offset=0,$condition='',$fields='*')
{
    $this->db->select($fields);
    if(isset($limit)&& $limit!='')
    {
        $this->db->limit($limit, $offset);
    }
    $this->db->from(USER_TABLE_NAME);
    if(isset($condition) && $condition != '')
    {
        $this->db->where($condition);
    }
    $this->db->order_by("firstname", "asc"); 
    $query = $this->db->get();
    echo $this->db->last_query(); // Get Last Query
    return $query->result_array();
}

在查看文件中

      if(isset($all_users)){
        if(isset($pagination))
        echo $pagination;
        }
于 2013-11-06T04:22:26.367 回答
0

尝试在视图页面中使用创建链接功能来显示不在控制器中的分页链接。

<?php echo $this->pagination->create_links(); ?>
于 2018-06-07T08:21:33.423 回答