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

php仿ZOL分页类代码

php 搞代码 4年前 (2022-01-01) 39次浏览 已收录 0个评论

模板zol网站的分页效果代码,效果如下图所示

代码如下:
<?php

/**
* 功能:分页类
* 作者:phpox
* 时间:Sat Jul 14 18:15:02 CST 2007
*/

defined(‘PHPOX’) or die(header(“HTTP/1.1 403 Not Forbidden”));

class page{
public $infocount;
public $pagecount;
public $items;
public $pageno;
public $start;
public $next;
public $prev;
public $maxpages;

public function __construct($infocount,$items,$pageno){
$this->infocount = $infocount;
$this->items = $items;
$this->pageno = $pageno;
$this->pagecount = $this->getpagecount();
$this->justpageno();
$this->start = $this->getstart();
$this->gotoprev();
$this->gotonext();
}

private function justpageno(){
if (emptyempty($this->pageno) || $this->pageno <1){
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount){
$this->pageno = $this->pagecount;
}
}

private function gotonext(){
$next = $this->pageno + 1;
if ($next > $this->pagecount){
$this->next = $this->pagecount;
}else {
$this->next = $next;
}

}

private function gotoprev(){
$prev = $this->pageno -1;
if ($prev <1){
$this->prev = 1;
}else {
$this->prev = $prev;
}
}

private function getpagecount(){
return ceil($this->infocount / $this->items);
}

private function getstart(){
if ($this->pageno <= 1){
return 0;
}else {
return ($this->pageno – 1) * $this->items;
}
}

/**
* 样式0(php)
*/
public function showpage($ctlname,$actname,$args = null){
if ($args !== null){
if (is_array($args)){
$str = ‘&’.encode_url_args($args);
}
}
$out = ”;
$out .= “每页显示{$this->items}条信息 “;
$out .= “当前页{$this->pageno}/{$this->pagecount} “;
$out .= “共有{$this->infocount}条信息 “;
$out .= “首页 “;
$out .= “prev}$str’>上一页 “;
$out .= “next}$str’>下一页 “;
$out .= “pagecount}$str’>尾页 “;
$out .= “跳转到:”;
$out .= “\n”;
$out .= ” 请选择\n”;
for ($i = 1;$i pagecount;$i++){
$out .= ” 第{$i}页\n”;
}
$out .= “\n”;
return $out;
}

/**
* 样式1(html)
*/
function htmlshowpage($path,$list,$film){
$out = ”;
$out .= “每页显示{$this->items}条信息 “;
$out .= “当前页{$this->pageno}/{$this->pagecount} “;
$out .= “共有{$this->infocount}条信息 “;
$out .= “首页 “;
$out .= “prev}.html’>上一页 “;
$out .= “next}.html’>下一页 “;
$out .= “pagecount}.html’>尾页 “;
$out .= “跳转到:”;
$out .= “\n”;
$out .= ” 请选择\n”;
for ($i = 1;$i pagecount;$i++){
$out .= ” 第{$i}页\n”;
}
$out .= “\n”;
return $out;
}

/**
* 样式2(discuz)
*/
function multi($mpurl,$page = 10) {

$multipage = ”;
$mpurl .= strpos($mpurl, ‘?’) !== false ? ‘&’ : ‘?’;
$realpages = 1;
if($this->infocount > $this->items) {
$offset = 2;

$realpages = @ceil($this->infocount / $this->items);
$pages = $this->maxpages && $this->maxpages maxpages : $realpages;

if($page > $pages) {
$from = 1;
$to = $pages;
} else {
$from = $this->pageno – $offset;
$to = $from + $page – 1;
if($from <1) {
$to = $this->pageno + 1 来源[email protected]搞@^&代*@码网– $from;
$from = 1;
if($to – $from <$page) {
$to = $page;
}
} elseif($to > $pages) {
$from = $pages – $page + 1;
$to = $pages;
}
}

$multipage = ($this->pageno – $offset > 1 && $pages > $page ? ‘1 …’ : ”).
($this->pageno > 1 ? ‘pageno – 1).'” class=”p_redirect”><<' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? ‘‘.$i.’‘ :”.$i.”;
}

$multipage .= ($this->pageno >>’ : ”).
($to <$pages ? '… '.$realpages.'' : '').
($pages > $page ? ‘‘ : ”);

$multipage = $multipage ? ‘

‘.$this->infocount.’ ‘.$this->pageno.’/’.$pages.’ ‘.$multipage.’

‘ : ”;
}
return $multipage;
}

/**
* 样式3(zol)
*/
public function zol($mpurl)
{
$mpurl .= strpos($mpurl, ‘?’) !== false ? ‘&’ : ‘?’;
$code = ‘

‘;
$code .= ‘

‘.$this->pageno.’/’.$this->pagecount.’页 每页‘.$this->items.’‘.$this->infocount.’款产品

‘;
$code .= ‘

‘;
$code .= ‘

‘;
if ($this->pageno == $this->prev)
{
$code .= “

“;
}
else
{
$code .= “

“;
}
$i = 10 ;
$k = 1;
if ($this->pageno <1)
{
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount)
{
$this->pageno = $this->pagecount;
}
$s = $this->pageno-2;
if ($s <= 0)
{
$s = 1;
}
$e = $this->pageno+2;
if ($e <5 )
{
$e = 5;
}
if ($e > $this->pagecount)
{
$e = $this->pagecount;
}
for ($j=$s;$j<=$e;$j++)
{
if ($this->pageno == $j)
{
$code .= ‘

‘;
}
else
{
$code .= “

“;
}
}
if ($this->pageno == $this->pagecount)
{
$code .= “

“;
}
else
{
$code .= “

“;
}
$code .= ‘

‘;
$code .= ‘

<<上一页prev}’ class=’a_lan12b’><<上一页‘.$j.’$j下一页>>next}’ class=’a_lan12b’>下一页>>

‘;
$code .= ‘

‘;
return $code;
}
}

以上就是php仿ZOL分页类代码的详细内容,更多请关注gaodaima搞代码网其它相关文章!


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

喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

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

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

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