请试试这个:
$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;
}