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]);         }       }
  • 相关阅读:
    数据结构与算法之二叉树的遍历
    数据结构与算法之二叉树
    数据结构与算法之单调栈
    数据结构与算法之栈
    C里面的变长参数
    C++模板问题之多出的static
    通过返回值'重载'函数
    flask小记
    ANSI C
    Python坑
  • 原文地址:https://www.cnblogs.com/junyi-bk/p/11507959.html
Copyright © 2011-2022 走看看