php仿ZOL分页类代码

前端之家收集整理的这篇文章主要介绍了php仿ZOL分页类代码前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

@H_301_0@大小: 3.86 K
尺寸: 289 x 42
浏览: 6 次
点击打开新窗口浏览全图


@H_301_0@大小: 3.31 K
尺寸: 215 x 52
浏览: 1 次
点击打开新窗口浏览全图


@H_301_0@大小: 5.56 K
尺寸: 500 x 46
浏览: 11 次
点击打开新窗口浏览全图
<div class="codetitle"><a style="CURSOR: pointer" data="28100" class="copybut" id="copybut28100" onclick="doCopy('code28100')"> 代码如下:
<div class="codebody" id="code28100">
<?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 .= "当前页

<font color=\"#FF0000\">{$this->pageno}/{$this->pagecount}

";
$out .= "共有{$this->infocount}条信息 ";
$out .= "首页 ";
$out .= "上一页 ";
$out .= "下一页 ";
$out .= "尾页 ";
$out .= "跳转到:";
$out .= "<select id=\"page\" name=\"page\" onchange=\"javascript:window.location='?ctl={$ctlname}&act={$actname}$str&p='+this.options[this.selectedIndex].value;\">\n";
$out .= " <option value=\"1\">请选择\n";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value=\"$i\">第{$i}页\n";
}
$out .= "\n";
return $out;
} /

样式1(html)
/
function htmlshowpage($path,$list,$film){
$out = '';
$out .= "每页显示{$this->items}条信息 ";
$out .= "当前页

<font color=\"#FF0000\">{$this->pageno}/{$this->pagecount}

";
$out .= "共有{$this->infocount}条信息 ";
$out .= "首页 ";
$out .= "上一页 ";
$out .= "下一页 ";
$out .= "尾页 ";
$out .= "跳转到:";
$out .= "<select id=\"page\" name=\"page\" onchange=\"javascript:window.location='{$path}html/$list/{$film}_'+this.options[this.selectedIndex].value +'.html'\">\n";
$out .= " <option value=\"1\">请选择\n";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value=\"$i\">第{$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 < $realpages ? $this->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 - $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 ? '<a href="'.$mpurl.'page=1" class="first">1 ...' : '').
($this->pageno > 1 ? '<a href="'.$mpurl.'page='.($this->pageno - 1).'" class="p_redirect"><<' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? '<a class="p_curpage">

'.$i.'

' :'<a href="'.$mpurl.'page='.$i.'" class="p_num">'.$i.'';
} $multipage .= ($this->pageno < $pages ? '<a href="'.$mpurl.'page='.($this->pageno + 1).'" class="p_redirect">>>' : '').
($to < $pages ? '<a href="'.$mpurl.'page='.$pages.'" class="last">... '.$realpages.'' : '').
($pages > $page ? '' : ''); $multipage = $multipage ? '<div class="p_bar"><a class="p_total"> '.$this->infocount.' <a class="p_pages"> '.$this->pageno.'/'.$pages.' '.$multipage.'
' : '';
}
return $multipage;
} /

样式3(zol)
/
public function zol($mpurl)
{
$mpurl .= strpos($mpurl,'?') !== false ? '&' : '?';
$code = '<div class="f22 mt10 hei14">';
$code .= '<div style="line-height:30px">第<font class="a_hong14b">'.$this->pageno.'<font class="a_hei14">/'.$this->pagecount.'页 每页<font class="a_hei14">'.$this->items.' 共<font class="a_hong14b">'.$this->infocount.'款产品
';
$code .= '<table border="0" align="right" cellpadding="0" cellspacing="3">';
$code .= '<tr>';
if ($this->pageno == $this->prev)
{
$code .= "<<上一页</td>";
}
else
{
$code .= "<<上一页</td>";
}
$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 .= '<td width="22" bgcolor="#2E6AB1" class="bei14" align="center">'.$j.'</td>';
}
else
{
$code .= "<td width='22' align='center' class='bd_lan a_lan14' onMouSEOver=\"this.style.border='1px solid #2062A4'\" onMouSEOut=\"this.style.border='1px solid #AACCEE'\" style=\"CURSOR: hand\" onClick=\"javascript:window.location=('{$mpurl}page={$j}')\">$j</td>";
}
}
if ($this->pageno == $this->pagecount)
{
$code .= "下一页>></td>";
}
else
{
$code .= "下一页>></td>";
}
$code .= '</tr>';
$code .= '</table>';
$code .= '
';
return $code;
}
}

php分页类

猜你在找的PHP相关文章