• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP分类页

php 搞代码 4年前 (2022-01-25) 22次浏览 已收录 0个评论
文章目录[隐藏]
<code><?php class Pagination_lib{    //总页数    public $all = 10;    //当前页    public $now = 1;    //选择器    public $seletor = "main_in_main";    //跳转地址    public $url = '';    public function init($all = 10,$now = 1,$seletor = "main_in_main",$url = ''){        $this->all = $all;        $this->now = $now;        $this->seletor = $seletor;        $this->url = $url;        if($this->now > $this->all ){            $this->all = 0;        }        if($this->now now = 1;        }    }    public function display(){        $str = "<ul class='pagination'>";//         if($this->all == 0){//             $str.="<div class='no_record'>没有相关记录</div>";//         }else{            if($this->all == 1){                $str.="<li class='active'>1<span class='sr-only'>(current)</span></li>";            }else{                if($this->now > 1 && $this->now < 6){                    $str.="<li>第一页</li>                            <li>now-1)."' >«</li>";                    for($i = 1; $i now; $i++) {                        $str.="<li>{$i}</li>";                    }                }elseif($this->now >= 6){                    $str.="<li>第一页</li>                    <li>now-1)." >«</li>                    <li>...</li>";                    for($i = $this->now-4; $i now; $i++) {                        $str.="<li>{$i}</li>";                    }                }                $str.="<li class='active'>{$this->now}<span class='sr-only'>(current)</span></li>";                if($this->all - $this->now > 4) {                    for($i = $this->now + 1; $i now + 4; $i++) {                        $str.="<li>{$i}</li>";                    }                    $str.="                    <li>...</li>                    <li>now+1)."' >»</li>                    <li>all}' >最后页</li>                    ";                }elseif($this->all - $this->now >= 1){                    for($i = $this->now + 1; $i all; $i++) {                        $str.="<li>{$i}</li>";                    }                    $str.="<li>now+1)."' >»</li>                            <li>all}' >最后页</li>";                }            }            $str.="<span class='goto'> 跳到now}'>页                    GO                    </span>                    </ul>                ";            $str.= "<style>.pagination {    width: 100%;    margin: 0px 0px;}.pagination .goto {  position: relative;  float: left;  height: 34px;  padding: 6px 12px;  line-height: 1.42857143;  margin-left: -1px;  width: 200px;  padding-left: 0;  margin-left: -4px;  margin-top: -4px;}.pagination  .goto-input{  font-family: inherit;  font-size: inherit;  line-height: inherit;  height: 32px;}.pagination .goto-btn{  margin-top: -3px;}                                </style>";//         }                            return $str;    }}?></code>

我想问问这种分页什么意思 怎么有js代码

回复内容:

<code><?php class Pagination_lib{    //总页数    public $all = 10;    //当前页    public $now = 1;    //选择器    public $seletor = "main_in_main";    //跳转地址    public $url = '';    public function init($all = 10,$now = 1,$seletor = "main_in_main",$url = ''){        $this->all = $all;        $this->now = $now;        $this->seletor = $seletor;        $this->url = $url;        if($this->now > $this->all ){            $this->all = 0;        }        if($this->now now = 1;        }    }    public function display(){        $str = "<ul class='pagination'>";//         if($this->all == 0){//             $str.="<div class='no_record'>没有相关记录</div>";//         }else{            if($this->all == 1){                $str.="<li class='active'>1<span class='sr-only'>(current)</span></li>";            }else{                if($this->now > 1 && $this->now < 6){                    $str.="<li>第一页</li>                            <li>now-1)."' >«</li>";                    for($i = 1; $i now; $i++) {                        $str.="<li>{$i}</li>";                    }                }elseif($this->now >= 6){                    $str.="<li>第一页</li>                    <li>now-1)." >«</li>                    <li>...</li><em style="color:transparent">本@文来源[email protected]搞@^&代*@码网(</em><q>搞代gaodaima码</q>";                    for($i = $this->now-4; $i now; $i++) {                        $str.="<li>{$i}</li>";                    }                }                $str.="<li class='active'>{$this->now}<span class='sr-only'>(current)</span></li>";                if($this->all - $this->now > 4) {                    for($i = $this->now + 1; $i now + 4; $i++) {                        $str.="<li>{$i}</li>";                    }                    $str.="                    <li>...</li>                    <li>now+1)."' >»</li>                    <li>all}' >最后页</li>                    ";                }elseif($this->all - $this->now >= 1){                    for($i = $this->now + 1; $i all; $i++) {                        $str.="<li>{$i}</li>";                    }                    $str.="<li>now+1)."' >»</li>                            <li>all}' >最后页</li>";                }            }            $str.="<span class='goto'> 跳到now}'>页                    GO                    </span>                    </ul>                ";            $str.= "<style>.pagination {    width: 100%;    margin: 0px 0px;}.pagination .goto {  position: relative;  float: left;  height: 34px;  padding: 6px 12px;  line-height: 1.42857143;  margin-left: -1px;  width: 200px;  padding-left: 0;  margin-left: -4px;  margin-top: -4px;}.pagination  .goto-input{  font-family: inherit;  font-size: inherit;  line-height: inherit;  height: 32px;}.pagination .goto-btn{  margin-top: -3px;}                                </style>";//         }                            return $str;    }}?></code>

我想问问这种分页什么意思 怎么有js代码

这个应该是分页类。传入分页数据(一页显示条数,页数,页码等)直接生成HTML代码和分页的数据

与楼上的回答一致… 生成分页好的点击样式直接输出成html页面代码.. 包含样式/点击跳转等…

其实就是图简单,php 直接输出 html,然后页面上就有分页按钮了,但是修改样式的时候就比较不好控制


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP分类页
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址