//

国产伦精品一区二区三区视频1,2020久热爱精品视频在线观看,91黄色国产精品,全集草久热的视频在线观看高清播放,精品国产在线免费视频,国产精品日韩高清伦字幕搜索,午夜作爱无码视频全集高清,国产精品成av电影不卡,免费成品网站源码1688免费推荐全集在线

Information for details

php常用類分享之分頁(yè)類

分頁(yè)處理類:

功能:實(shí)現(xiàn)分頁(yè)技術(shù)。

本文實(shí)例講述了PHP實(shí)現(xiàn)的簡(jiǎn)單分頁(yè)類及其詳細(xì)的使用方法。分享給大家供大家參考,具體如下

<?php
/**
 * 分頁(yè)類
*/

class page{
    
    protected $url;//傳入的URL
    protected $count;//總頁(yè)數(shù)
    public $num;//每頁(yè)顯示的數(shù)量
    protected $total;//總記錄數(shù),總條數(shù)              
    protected $prevnum;//上一頁(yè)數(shù)
    protected $nextnum;//下一頁(yè)數(shù)      
    protected $prev='上一頁(yè)';//上一頁(yè)
    protected $next='下一頁(yè)';//下一頁(yè)
    protected $first='首頁(yè)';//首頁(yè)          
    protected $last='尾頁(yè)';//尾頁(yè)
    protected $start;//開(kāi)始記錄數(shù)
    protected $end;//結(jié)束記錄數(shù)
    protected $page;//當(dāng)前頁(yè)

    //初始化成員方法 URL 總數(shù) 每頁(yè)顯示數(shù)
    public function __construct($url,$total,$num=10){
        
        $this->url=$url;//填入的url地址
        $this->total=$total;//條目總數(shù)
        $this->num=$num;//每頁(yè)顯示數(shù)
        $this->page=$_GET['page']?$_GET['page']:1;//獲得當(dāng)前的頁(yè)數(shù)
        $this->count=$this->getcount();//總頁(yè)數(shù)
        $this->prevnum=$this->getprevnum();//獲得上一頁(yè)數(shù)
        $this->nextnum=$this->getnextnum();//獲得下一頁(yè)數(shù)
        $this->start=$this->getstart();//開(kāi)始記錄數(shù)
        $this->end=$this->getend();//結(jié)束記錄數(shù)
        var_dump($this->page);
    }
    
    //獲得總數(shù)的方法
    protected  function getcount(){
        return ceil($this->total/$this->num);
    }
    
    //獲得開(kāi)始記錄數(shù)
    protected function getstart(){
        return ($this->page-1)*$this->num+1;
    }
    
    //獲得結(jié)束記錄數(shù)
    protected function getend(){
        return min($this->page*$this->num,$this->total);
    }
    
    //獲得上一頁(yè)的方法
    protected function getprevnum(){
        if($this->page<=1){
            return false;
        }else{
            return $this->page-1;
        }
    }
    
    //獲得下一頁(yè)的方法
    protected function getnextnum(){
        if($this->page>=$this->count){
            return false;
        }else{
            return $this->page+1;
        }
    }
    
    //獲得分頁(yè)的偏移量
    public function offset(){
        return ($this->page-1)*$this->num;
    }
    
    //公共方法
    public function showpage(){
        //顯示效果為:這是第n頁(yè) 共n頁(yè) 從n到x記錄 首頁(yè) 上一頁(yè) 下一頁(yè) 尾頁(yè)  
        $string='這是第'.$this->page.'頁(yè) &nbsp;共'.$this->count.'頁(yè)&nbsp;';
        $string.='從第'.$this->start.'條到第'.$this->end.'條記錄';
        $string.='<a href="'.$this->url.'page=1">首頁(yè)</a> &nbsp;&nbsp;&nbsp;&nbsp;';
        if($this->prevnum){
            $string.='<a href="'.$this->url.'page='.$this->prevnum.'">上一頁(yè)</a>&nbsp&nbsp&nbsp';
        }
        if($this->nextnum){
            $string.='<a href="'.$this->url.'page='.$this->nextnum.'">下一頁(yè)</a>&nbsp&nbsp&nbsp';
        }
        $string.='<a href="'.$this->url.'page='.$this->count.'">尾頁(yè)</a>';
        return $string;
    }
}
?>

云南然成科技有限公司是一家云南本土的獲得省科技廳、省財(cái)政廳、省國(guó)稅局、地稅局等機(jī)構(gòu)認(rèn)定的高新技術(shù)企業(yè)。公司定位于高端網(wǎng)站設(shè)計(jì)、系統(tǒng)開(kāi)發(fā)、APP開(kāi)發(fā)、微信公眾號(hào)、微信小程序開(kāi)發(fā)。擁有多個(gè)軟著權(quán),公司先后為多家事業(yè)單位提供服務(wù),比如會(huì)澤文化館、宣威文化館、中科院昆明植物研究所等。其中中國(guó)科學(xué)院昆明植物研究所已經(jīng)進(jìn)行了長(zhǎng)達(dá)4年的合作,并且還持續(xù)合作中!

  • 滇公網(wǎng)安備 53010202001388號(hào)