zoukankan      html  css  js  c++  java
  • php(tp5)实现分页效果

          public function admin(){
            if(request()->isPost()){
              //获取第二页的数据传current = 2过来即可
              $post['origin'] = input('origin');
                    $post['lenght'] = input('lenght');
                    $post['current'] = input('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['data'] = AdminModel::admin_lst($post['origin'],$post['lenght']);
    
                    //数据总条数
                    $data['count'] = StudyModel::rules_count();
    
                    //总页数
                    $data['page'] = ceil($data['count'] / $data['lenght']); 
              return json(['code'=>1,'data'=>$data]);         }       }
  • 相关阅读:
    静态连接库
    03数据的增删改查
    02MySQL中的数据类型
    01MySQL的 库、表初步认识
    Python 函数
    Linux系统目录结构
    Linux系统启动过程
    第三章 Web页面建设
    《第二章:深入了解超文本》
    《HTML与CSS 第一章 认识HTML》读书笔记
  • 原文地址:https://www.cnblogs.com/junyi-bk/p/11507959.html
Copyright © 2011-2022 走看看