php(tp5)實現分頁效果


      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']);  
        }    
      }

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM