码迷,mamicode.com
首页 > 其他好文 > 详细

Codeigniter入门学习笔记10—分页

时间:2016-05-09 17:03:36      阅读:220      评论:0      收藏:0      [点我收藏+]

标签:

  • 很久很久以前学习Codeigniter的笔记记录,很随意,但都是自己记录的,希望对需要的人有所帮助。
  • 本文使用word2013编辑并发布
  • Postbird | There I am , in the world more exciting!
  • Postbird personal website : http://www.ptbird.cn

    ?

    分页

技术分享

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);

????????}

Codeigniter入门学习笔记10—分页

标签:

原文地址:http://www.cnblogs.com/postbird/p/5474564.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!