控制器
public function cust_list() {
$this->load->model('cus_model');
$config["base_url"] = base_url() . "cus_controller/cust_list/";
$config["total_rows"] = $this->cus_model->num_rows();
$config["per_page"] = 5;
$config['cur_tag_open'] = ' <a class="current">';
$config['cur_tag_close'] = '</a>';
$config['next_link'] = 'Next';
$config['prev_link'] = 'Previous';
$this->pagination->initialize($config);
if($this->uri->segment(3)){
$page = $this->uri->segment(3);
}else{
$page = 0;
}
$this->data["customers"] = $this->cus_model-
>customer_list($config["per_page"], $page);
$str_links = $this->pagination->create_links();
$this->data["links"] = explode(' ',$str_links );
$this->load->view('salonadmin/customerview',$this->data);
}
模型
public function customer_list($limit,$offset){
$query = $this->db->select('*')->from('customer')->limit( $limit,$offset
)->get()->result();
return $query;
}
public function num_rows()
{
$query = $this->db->select('*')->from('customer')->get()->num_rows();
return $query;
}
视图
<-- Pagination Link -->
<ul class="pagination pull-right">
<?php foreach ($links as $link) {
echo "<li>". $link."</li>";
} ?>
</ul>