PHP   发布时间:2019-11-12  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了CodeIgniter分页类pagination使用方法示例大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

本文实例讲述了CodeIgniter分页类pagination使用方法。分享给大家供大家参,具体如下:

controller控制器(application/controller/page.php文件):

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['@R_513_10586@l_rows'] = $result['@R_513_10586@l'];//总条数 $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'],'@R_513_10586@l' => $result['@R_513_10586@l'],'current_page' => $current_page,'per_page' => $config['per_page'],'page' => $this->pagination->create_links(),); $this->load->view ( 'admin/home',$result ); } @H_801_5@
@H_206_0@model模型(application/model/home_model.php文件):

db->query( "SELECT Name_cn,Mall_type,create_time FROM smzdm_mall WHERE Is_deleted = 0 order by {$order} limit {$offset},{$num}"); return array( '@R_513_10586@l' => $this->db->count_all('smzdm_mall',array('Is_deleted'=>'0')),'list' => $query->result(),); } @H_801_5@

更多关于CodeIgniter相关内容感兴趣的读者可查看本站专题:《》、《》、《》、《》、《》、《》及《php常见数据库操作技巧汇总》

希望本文所述对大家基于CodeIgniter框架的php程序设计有所帮助。

大佬总结

以上是大佬教程为你收集整理的CodeIgniter分页类pagination使用方法示例全部内容,希望文章能够帮你解决CodeIgniter分页类pagination使用方法示例所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。
标签:分页类