zoukankan      html  css  js  c++  java
  • 以前用的页码类,忘记怎么用了,放这里备忘。

    以前一个cms后台用的翻页按钮类,1|2|……456789……999

    放这里保存起来

    /*
    $mypagenav=new pagelinknav();
    $mypagenav->pageurl="t2.php?";
    $mypagenav->pageint($_GET['page'],50,2,5);
    
    *    css 样式
    .pagenav{  960px;background-color: #ffffff;height:auto!important;height:42px;min-height:42px;}
    .pagenavNBbox{line-height: 40px;padding-left: 10px;padding-right: 10px;float: left ;border: 1px #dddddd solid;margin-right: 10px; 48px;text-align: center }
    .pagenavNBboxblock{line-height: 40px;padding-left: 10px;padding-right: 10px;float: left ;border: 1px #FFFFFF solid;margin-right: 10px; 48px;text-align: center }
    .pagenavDDbox{ line-height: 40px;padding-left: 10px;padding-right: 10px;float: left ;border: 1px #FFFFFF solid;margin-right: 10px;text-align: center}
    .pagenavbox{auto!important;20px;min-20px; line-height: 40px;padding-left: 10px;padding-right: 10px;float: left ;border: 1px #dddddd solid;margin-right: 10px;text-align: center}
    .pagenavboxon{ color:#ffffff;font-weight: bold ;background-color: #6092b7;border: 1px #6092b7 solid;auto!important;20px;min-20px; line-height: 40px;padding-left: 10px;padding-right: 10px;float: left ;margin-right: 10px;text-align: center}
    */
    
    class pagelinknav{
        public $pageurl;
        public $inpage;
        function    pageint($page1,$page2,$page3,$page4){
            $this->inpage=$page1;
            $_inpage=$page1;
            $_totalpage=$page2;
            $_pageb=$page3;                        //最前显示页码数量
            $_pagec=$page4;                        //最好为奇数
            $_pagei=1;
            //div head
            echo "<div class='pagenav'>";
            //start pagenumber area a
            if($_inpage>1){
                $this->pageBBshow("« 上一页",$_inpage-1,"pagenavNBbox",1);
            }else{
                //echo "[NONE]";
                $this->pageBBshow("共".$_totalpage."页",$_inpage,"pagenavNBbox",2);
            }
            //start pagenumber area b
            while($_pagei <= $_totalpage and $_pagei <=$_pageb){
                $this->pageshow($_pagei,$_pagei,"pagenavbox");
                //echo "[".$_pagei."]";
                $_pagei++;
            }
            //start pagenumber area c1
            if(($_inpage-$_pageb)>ceil($_pagec/2) and $_inpage <= $_totalpage){
                $this->pageDDshow("...","...","pagenavDDbox");
                //echo "...";
            }
            //start pagenumber area c2
            if($_inpage <= $_totalpage){
                if(($_inpage-$_pageb)<=$_pageb){
                    $_pagei=$_pageb+1;
                }elseif(($_totalpage-$_inpage)<ceil($_pagec/2)){
                    $_pagei=($_totalpage-$_pagec)+1;
                    //die($_totalpage-($_totalpage-$_inpage)."-");
                    //echo $_pagei;
                }
                else{
                    $_pagei=$_inpage-$_pageb;
                }
                $_pageic=$_pagei+$_pagec;
                while($_pagei<$_pageic and $_pagei <= $_totalpage){
                    $this->pageshow($_pagei,$_pagei,"pagenavbox");
                    //echo "[".$_pagei."]";
                    $_pagei++;
                }
            }
            //start pagenumber area c3
            if(($_totalpage-$_inpage)>=ceil($_pagec/2) and $_inpage <= $_totalpage){
                $this->pageDDshow("...","...","pagenavDDbox");
                //echo "A".ceil($_pagec/2);
                //echo "...";
            }
    
            //start pagenumber area d
            if($_inpage<$_totalpage){
                //echo "[NEXT]";
                $this->pageNBshow("下一页 »",$_inpage+1,"pagenavNBbox",1);
            }else{
                //echo "[NONE]";
                $this->pageNBshow("没有啦",$_inpage,"pagenavNBbox",2);
            }
            //div foot
            echo "</div>";
        }
        function    pageBBshow($pgmsg,$pplink,$pdclass,$pptype){
            if($pptype==1){
                echo "<div class='".$pdclass."'>";
                echo "<a href='".$this->pageurl."page=".$pplink."'>";
                echo $pgmsg;
                echo "</a>";
                echo "</div>";
            }else{
                echo "<div class='".$pdclass."'>";
                echo $pgmsg;
                echo "</div>";
            }
        }
        function    pageNBshow($pgmsg,$pplink,$pdclass,$pptype){
            if($pptype==1){
                echo "<div class='".$pdclass."'>";
                echo "<a href='".$this->pageurl."page=".$pplink."'>";
                echo $pgmsg;
                echo "</a>";
                echo "</div>";
            }else{
                echo "<div class='".$pdclass."'>";
                echo $pgmsg;
                echo "</div>";
            }
        }
        function    pageDDshow($pgmsg,$pagenum,$pdclass){
            echo "<div class='".$pdclass."'>";
            echo $pgmsg;
            echo "</div>";
        }
        function    pageshow($pgmsg,$pagenum,$pdclass){
            if($this->inpage!="$pagenum"){
                $pdclass="pagenavbox";
                echo "<div class='".$pdclass."'>";
                echo "<a href='".$this->pageurl."page=".$pagenum."'>";
                echo $pgmsg;
                echo "</a>";
                echo "</div>";
            }else{
                $pdclass="pagenavboxon";
                echo "<div class='".$pdclass."'>";
                echo $pgmsg;
                echo "</div>";
            }
        }
    }
  • 相关阅读:
    layui多选框
    js获取html5 audio 音频时长方法
    危害程序员职业生涯的三大观念
    选择器
    C++ STL partial_sort
    C++ STL sort
    C++ STL 排列 next_permutation prev_permutation
    C++ STL 逆转旋转 reverse reverse_copy rotate
    C++ unique
    C++ remove remove_if erase
  • 原文地址:https://www.cnblogs.com/code123/p/3356894.html
Copyright © 2011-2022 走看看