首页 > Web开发 > 详细

php(tp5)实现分页效果

时间:2019-09-11 20:38:33      阅读:102      评论:0      收藏:0      [点我收藏+]
      public function admin(){
        if(request()->isPost()){
          //获取第二页的数据传current = 2过来即可
          $post[‘origin‘] = input(‘request.origin‘);
                $post[‘lenght‘] = input(‘request.lenght‘);
                $post[‘current‘] = input(‘request.current‘);
                //当前数据开始查询位置
                if ( !isset($post[‘origin‘]) || empty($post[‘origin‘]) ) {
                    $post[‘origin‘] = 0 ;
                }

                //每页显示多少条数据
                if ( !isset($post[‘lenght‘]) || empty($post[‘lenght‘]) ) {
                    $post[‘lenght‘] = 6 ;
                }

                //当前页
                if ( isset($post[‘current‘]) && !empty($post[‘current‘]) && $post[‘current‘]>=1 ) {
                    $data[‘current‘] = ceil($post[‘current‘]);
                    if (($data[‘current‘]-1)>=1){
                        $post[‘origin‘] = ($post[‘current‘]-1) * $post[‘lenght‘];
                    }
                }else{

                    $data[‘current‘] =  $post[‘origin‘] / $post[‘lenght‘];
                }


                $data[‘lenght‘] = $post[‘lenght‘];
                if ($data[‘current‘]<=1) {
                    $data[‘current‘] = 1;
                }
          //数据    
                $data[‘admin‘] = AdminModel::admin_lst($post[‘origin‘],$post[‘lenght‘]);

                //数据总条数
                $data[‘count‘] = StudyModel::rules_count();

                //总页数
                $data[‘page‘] = ceil($data[‘count‘] / $data[‘lenght‘]);  
        }    
      }

 

php(tp5)实现分页效果

原文:https://www.cnblogs.com/junyi-bk/p/11507959.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!