标签:
?
分页
public function fenye(){
????????????//加载分页的控制器
????????????????$this->load->library(‘pagination‘);
????????????????$this->load->helper(‘url‘);
????????????//基础配置????
????????????????$page_size=10;
????????????????$config[‘base_url‘]=site_url(‘user/fenye‘);//连接
????????????????$config[‘total_rows‘]=100;//总共有多少条数据
????????????????$config[‘per_page‘]=$page_size;//每页显示条数
????????????????$config[‘first_link‘]="首页";
????????????????$config[‘last_link‘]="尾页";
????????????????$config[‘next_link‘]=">>>>";
????????????????$config[‘prev_link‘]="<<<<";
????????????????$config[‘uri_segment‘]=3;//默认是3
????????????//初始化????
????????????????$this->pagination->initialize($config);
?
????????????//分页查询偏移量
????????????????$offset=intval($this->uri->segment(3));
????????????????$sql="select * from blog_user limit $offset,$page_size";
????????????????echo $sql;
????????????//创建连接
????????????????$data[‘links‘]=$this->pagination->create_links();
????????????//引入view????
????????????????$this->load->view(‘header‘);
????????????????$this->load->view(‘user/fenye‘,$data);
????????}
标签:
原文地址:http://www.cnblogs.com/postbird/p/5474564.html