<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,然后页面上就有分页按钮了,但是修改样式的时候就比较不好控制