php 分頁類(源碼+執行個體)

來源:互聯網
上載者:User
分享一個php分頁類,寫的不錯,提供了二個該分頁類的調用執行個體,供大家學習參考。

1,php分頁類代碼

        Number        =    $number;    $this->        N_p_p        =    $n_p_p;     $this->        Pages        =    ceil    (    $this->    Number    /    $this->    N_p_p    )    ;     $this->        Buttons        =    $buttons        ;     $page_number=    ($page_number>$this->Pages)    ?    $this->Pages    :    $page_number    ;     $this->        Page_number    =    $page_number    ;     $this->        Ret()    ;     }  public function Show_Pagination($link,$get='page',$div_class_name='pagination')     {     //if pages == 1 , no need to print pagination     if($this->Pages==1)return;     //$link is the addres of current page          //$get is name of get method     //echo pagination's div          echo'';     //echo pre button          if($this->Page_number>1)echo 'Page_number -1 ).'">Per ';     else echo 'Per ';          //print button    $this->Buttons=(int)$this->Buttons;    $start_counter    =    $this->Page_number-floor($this->Buttons/2);//for normal mode    $end_conter        =    $this->Page_number+floor($this->Buttons/2);//for normal mode    //try to buttons exactly equal to $Buttons        if($start_counter<1) $end_conter=$end_conter+abs($start_counter);    if($end_conter>$this->Pages) $start_counter=$start_counter-($end_conter-$this->Pages);    if(($this->Page_number-floor($this->Buttons/2))<1)$end_conter ++;              for ($i=$start_counter;$i<=$end_conter;$i++) {      if($i>$this->Pages || $i<1)continue;        //no print less than 1 value or grater than totall page      if($i==$this->Page_number)echo ' '.$i.' ';         // change current page' class      else echo ' '.$i.' ';      // normal pages      }           //echo next button          if($this->Page_number<$this->Pages)echo 'Page_number +1 ) .'">Nex ';          else echo 'Nex ';                  //close div tag          echo'';          }     //give the page number and return start and end of selection   private function  Ret()     {     $this->Start=(($this->Page_number-1)*$this->N_p_p);     $this->End=  $this->N_p_p ;     } }

2,分頁類的樣本一

   php分頁類樣本---bbs.it-home.org  Start , $pagination->End"); //echo your result while($row=mysql_fetch_assoc($SecondQuery))     {         echo 'id='.$row['id'].'
'; }//show pagination: $pagination->Show_Pagination("ExampleMysql.php?param1=value1",'page','pagination'); ?>

3,分頁類的調用樣本二

   php分頁類的調用樣本-bbs.it-home.org  Start , $cat->End //for show : $cat->Show_Pagination("example.php?",'page','pagination'); ?> 
  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.