CodeIgniter分页类pagination使用方法示例,codeigniter示例_PHP教程
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了CodeIgniter分页类pagination使用方法示例,codeigniter示例_PHP教程,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含2722字,纯文字阅读大概需要4分钟。
内容图文
![CodeIgniter分页类pagination使用方法示例,codeigniter示例_PHP教程](/upload/InfoBanner/zyjiaocheng/191/5510e8a53b274539a4d266f77745fca5.jpg)
CodeIgniter分页类pagination使用方法示例,codeigniter示例
本文实例讲述了CodeIgniter分页类pagination使用方法。分享给大家供大家参考,具体如下:
controller控制器(application/controller/page.php文件):
public function index() { $this->load->model ( 'home_model' , '' , TRUE); $config= array(); $config['per_page'] = $this->per_page; //每页显示的数据数 $current_page = intval($this->input->get_post('per_page',true)); //获取当前分页页码数 //page还原 if(0 == $current_page) { $current_page = 1; } $offset = ($current_page - 1 ) * $config['per_page']; //设置偏移量 限定 数据查询 起始位置(从 $offset 条开始) $result = $this->home_model->index($offset,$config['per_page'],$order='id desc'); $config['base_url'] = $this->config->item('base_url').'admin/home/index?'; $config['first_link'] = $this->first_link;//首页 $config['prev_link'] = $this->prev_link;//上一页 $config['next_link'] = $this->next_link;//下一页 $config['last_link'] = $this->last_link;//尾页 $config['total_rows'] = $result['total'];//总条数 $config['num_links'] = 3;//页码连接数 $config['use_page_numbers'] = TRUE; $config['page_query_string'] = TRUE; $this->load->library('pagination');//加载ci pagination类 $this->pagination->initialize($config); $result = array( 'list' => $result['list'], 'total' => $result['total'], 'current_page' => $current_page, 'per_page' => $config['per_page'], 'page' => $this->pagination->create_links(), ); $this->load->view ( 'admin/home' , $result ); }
model模型(application/model/home_model.php文件):
public function index($offset,$num,$order='id desc') { $query = $this->db->query( "SELECT Name_cn,Mall_type,create_time FROM smzdm_mall WHERE Is_deleted = 0 order by {$order} limit {$offset},{$num}"); return array( 'total' => $this->db->count_all('smzdm_mall',array('Is_deleted'=>'0')), 'list' => $query->result(), ); }
更多关于CodeIgniter相关内容感兴趣的读者可查看本站专题:《codeigniter入门教程》、《CI(CodeIgniter)框架进阶教程》、《php日期与时间用法总结》、《php面向对象程序设计入门教程》、《php字符串(string)用法总结》、《php+mysql数据库操作入门教程》及《php常见数据库操作技巧汇总》
希望本文所述对大家基于CodeIgniter框架的PHP程序设计有所帮助。
您可能感兴趣的文章:
- CodeIgniter使用smtp服务发送html邮件的方法
- codeigniter发送邮件并打印调试信息的方法
- Codeigniter发送邮件的方法
- Codeigniter实现发送带附件的邮件
- CodeIgniter辅助之第三方类库third_party用法分析
- CodeIgniter扩展核心类实例详解
- CI(Codeigniter)的Setting增强配置类实例
- php实现仿写CodeIgniter的购物车类
- Codeigniter的dom类用法实例
- Codeigniter购物车类不能添加中文的解决方法
- CodeIgniter基于Email类发邮件的方法
http://www.bkjia.com/PHPjc/1117097.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/1117097.htmlTechArticleCodeIgniter分页类pagination使用方法示例,codeigniter示例 本文实例讲述了CodeIgniter分页类pagination使用方法。分享给大家供大家参考,具体如下:...
内容总结
以上是互联网集市为您收集整理的CodeIgniter分页类pagination使用方法示例,codeigniter示例_PHP教程全部内容,希望文章能够帮你解决CodeIgniter分页类pagination使用方法示例,codeigniter示例_PHP教程所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。