PHP分类页

WBOY
Release: 2016-06-06 20:13:00
Original
907 people have browsed it

<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"><a href="javascript:;" data-href="1">1<span class="sr-only">(current)</span></a></li>";
            }else{
                if($this->now > 1 && $this->now <a href="javascript:;" data-href="1">第一页</a>
                            <li><a href="javascript:;" data-href='".($this->now-1)."'>«</a></li>";
                    for($i = 1; $i now; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                }elseif($this->now >= 6){
                    $str.="<li><a href="javascript:;" data-href="1">第一页</a></li>
                    <li><a href="javascript:;" data-href=".($this->now-1).">«</a></li>
                    <li><a href="javascript:void(0)">...</a></li>";
                    for($i = $this->now-4; $i now; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                }
                $str.="<li class="active"><a href="javascript:void(0)">{$this->now}<span class="sr-only">(current)</span></a></li>";
                if($this->all - $this->now > 4) {
                    for($i = $this->now + 1; $i now + 4; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                    $str.="
                    <li><a href="javascript:void(0)">...</a></li>
                    <li><a href="javascript:;" data-href='".($this->now+1)."'>»</a></li>
                    <li><a href="javascript:;" data-href="{$this->all}">最后页</a></li>
                    ";
                }elseif($this->all - $this->now >= 1){
                    for($i = $this->now + 1; $i all; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                    $str.="<li><a href="javascript:;" data-href='".($this->now+1)."'>»</a></li>
                            <li><a href="javascript:;" data-href="{$this->all}">最后页</a></li>";
                }
            }
            $str.="<span class="goto"> 跳到<input type="text" class="goto-input" id="goto-input" maxlength="5" value="{$this->now}">页
                    <a href="javascript:void(0)" class="btn btn-default btn-sm goto-btn" id="goto-btn">GO</a>
                    </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>
Copy after login
Copy after login

我想问问这种分页什么意思 怎么有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"><a href="javascript:;" data-href="1">1<span class="sr-only">(current)</span></a></li>";
            }else{
                if($this->now > 1 && $this->now <a href="javascript:;" data-href="1">第一页</a>
                            <li><a href="javascript:;" data-href='".($this->now-1)."'>«</a></li>";
                    for($i = 1; $i now; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                }elseif($this->now >= 6){
                    $str.="<li><a href="javascript:;" data-href="1">第一页</a></li>
                    <li><a href="javascript:;" data-href=".($this->now-1).">«</a></li>
                    <li><a href="javascript:void(0)">...</a></li>";
                    for($i = $this->now-4; $i now; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                }
                $str.="<li class="active"><a href="javascript:void(0)">{$this->now}<span class="sr-only">(current)</span></a></li>";
                if($this->all - $this->now > 4) {
                    for($i = $this->now + 1; $i now + 4; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                    $str.="
                    <li><a href="javascript:void(0)">...</a></li>
                    <li><a href="javascript:;" data-href='".($this->now+1)."'>»</a></li>
                    <li><a href="javascript:;" data-href="{$this->all}">最后页</a></li>
                    ";
                }elseif($this->all - $this->now >= 1){
                    for($i = $this->now + 1; $i all; $i++) {
                        $str.="<li><a href="javascript:;" data-href="{$i}">{$i}</a></li>";
                    }
                    $str.="<li><a href="javascript:;" data-href='".($this->now+1)."'>»</a></li>
                            <li><a href="javascript:;" data-href="{$this->all}">最后页</a></li>";
                }
            }
            $str.="<span class="goto"> 跳到<input type="text" class="goto-input" id="goto-input" maxlength="5" value="{$this->now}">页
                    <a href="javascript:void(0)" class="btn btn-default btn-sm goto-btn" id="goto-btn">GO</a>
                    </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>
Copy after login
Copy after login

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

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

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

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

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template