巅云智能建站平台搭建版(创业门户版)火爆上线,终身授权!新增:文章智能采集+全站真静态打包+城市分站+智能小程序+非法词过滤+H5自适应+智能链词等功能功能详情
帮助文档Help

php仿ZOL分页类代码

一佰互联网站制作(www.yinxi.net) 发布日期 2019-05-01 19:06:17 浏览数: 133


复制代码 代码如下:
<?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 .= "当前页<strong><font color="#FF0000">{$this->pageno}</font>/{$this->pagecount}</strong> ";
$out .= "共有{$this->infocount}条信息 ";
$out .= "<a href="?ctl={$ctlname}&act={$actname}&p=1$str">首页</a> ";
$out .= "<a href="?ctl={$ctlname}&act={$actname}&p={$this->prev}$str">上一页</a> ";
$out .= "<a href="?ctl={$ctlname}&act={$actname}&p={$this->next}$str">下一页</a> ";
$out .= "<a href="?ctl={$ctlname}&act={$actname}&p={$this->pagecount}$str">尾页</a> ";
$out .= "跳转到:";
$out .= "<select id="page" name="page" onchange="javascript:window.location="?ctl={$ctlname}&act={$actname}$str&p="+this.options[this.selectedIndex].value;"> ";
$out .= " <option value="1">请选择</option> ";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value="$i">第{$i}页</option> ";
}
$out .= "</select> ";
return $out;
}

/**
* 样式1(html)
*/
function htmlshowpage($path,$list,$film){
$out = "";
$out .= "每页显示{$this->items}条信息 ";
$out .= "当前页<strong><font color="#FF0000">{$this->pageno}</font>/{$this->pagecount}</strong> ";
$out .= "共有{$this->infocount}条信息 ";
$out .= "<a href="{$path}$list/{$film}_1.html">首页</a> ";
$out .= "<a href="{$path}$list/{$film}_{$this->prev}.html">上一页</a> ";
$out .= "<a href="{$path}$list/{$film}_{$this->next}.html">下一页</a> ";
$out .= "<a href="{$path}$list/{$film}_{$this->pagecount}.html">尾页</a> ";
$out .= "跳转到:";
$out .= "<select id="page" name="page" onchange="javascript:window.location="{$path}html/$list/{$film}_"+this.options[this.selectedIndex].value +".html""> ";
$out .= " <option value="1">请选择</option> ";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value="$i">第{$i}页</option> ";
}
$out .= "</select> ";
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 ...</a>" : "").
($this->pageno > 1 ? "<a href="".$mpurl."page=".($this->pageno - 1)."" class="p_redirect"><<</a>" : "");
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? "<a class="p_curpage"><strong>".$i."</strong></a>" :"<a href="".$mpurl."page=".$i."" class="p_num">".$i."</a>";
}

$multipage .= ($this->pageno < $pages ? "<a href="".$mpurl."page=".($this->pageno + 1)."" class="p_redirect">>></a>" : "").
($to < $pages ? "<a href="".$mpurl."page=".$pages."" class="last">... ".$realpages."</a>" : "").
($pages > $page ? "<kbd><input type="text" name="custompage" size="3" onkeydown="if(event.keyCode==13) {window.location="".$mpurl."page="+this.value; return false;}" /></kbd>" : "");

$multipage = $multipage ? "<div class="p_bar"><a class="p_total"> ".$this->infocount." </a><a class="p_pages"> ".$this->pageno."/".$pages." </a>".$multipage."</div>" : "";
}
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><font class="a_hei14">/".$this->pagecount."</font>页 每页<font class="a_hei14">".$this->items."</font> 共<font class="a_hong14b">".$this->infocount."</font>款产品</div>";
$code .= "<table border="0" align="right" cellpadding="0" cellspacing="3">";
$code .= "<tr>";
if ($this->pageno == $this->prev)
{
$code .= "<td width="64" align="center" class="bd_hui huei14b"><a disabled="disabled" class="a_hui12b"><<上一页</a></td>";
}
else
{
$code .= "<td width="64" align="center" class="bd_lan a_lan14"><a href="{$mpurl}page={$this->prev}" class="a_lan12b"><<上一页</a></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 align="center" width="64" class="bd_hui huei14b"><a disabled="disabled" >下一页>></a></td>";
}
else
{
$code .= "<td align="center" width="64" class="bd_lan lan14b"><a href="{$mpurl}page={$this->next}" class="a_lan12b">下一页>></a></td>";
}
$code .= "</tr>";
$code .= "</table>";
$code .= "</div>";
return $code;
}
}

TAG标签: php仿ZOL分页类代码  
一佰互联是全国知名建站品牌服务商,我们有九年网站建设网站制作、网页设计、php开发和域名注册及虚拟主机服务经验,提供的自助建站服务更是全国有名。近年来还整合团队优势自主开发了可视化多用户”巅云建站系统“3.0平台版,拖拽排版网站制作设计,轻松实现pc站、手机微网站、小程序、APP一体化全网营销网站建设 ,已成功的为全国上百家网络公司提供自助建站平台搭建服务。

相关新闻more

17
04月
网店低价热卖丰胸精油 月卖10万元竟是冒牌货

一丰胸精油产品在多家网店淘宝热卖,月销10万元,原来竟是冒牌货。广州白云警方日前破获这宗网络售假案,并抓获2名售假嫌疑人,查获假冒注册产品共... >>详情

15
05月
花不同的钱制作不同的手机网站,收益移动端市场

window._bd_share_config={"common":{"bdSnsKey":{},"bdText":"","bdMini":... >>详情

27
03月
群控,电脑控制手机批量加粉,自动精准营销

简介:说到精准引流加粉的系统工具,就不得不提到目前营销界大热的手机群控系统。手机群控,用1台电脑就能控制多部(最多100部)手机的自动化智能... >>详情

08
04月
隐秘而伟大!Facebook 好友图标的设计

Facebook 总部是一个神奇的地方,小吃是免费的,阳光永远明媚,每个人都满脑子好点子。来这里的第一周,我碰到的每一个人都努力让这个世界更... >>详情

高端网站建设

美工兼顾SEO,为企业电子商务营销助力!

电话:

023-85725751
建站

产品

域名注册 虚拟主机 云服务器 企业邮局
智能建站 APP打包 微站/小程序 创业平台
网站推广 媒体营销 智能采集 AI机器人
400电话 短信营销 店销机器人
私人定制 门户网站