时间:2016-02-24 19:07 来源: 我爱IT技术网 作者:佚名
欢迎您访问我爱IT技术网,今天小编为你分享的编程技术是:【php分页类】,下面是详细的分享!
php分页类
<?php//
// +----------------------------------------------------------------------+
// | 分页类 |
// +----------------------------------------------------------------------+
// | Copyright (c) 2001 NetFish Software |
// | |
// | Author: whxbb(whxbbh@21cn.com) |
// +----------------------------------------------------------------------+
//
// $Id: pager.class.php,v 0.1 2001/8/2 13:18:13 yf Exp $
//
// 禁止直接访问该页面
if (basename($HTTP_SERVER_VARS['PHP_SELF'])=="pager.class.php") {
header("HTTP/1.0 404 Not Found");
}
class Pager
{
var $infoCount;
var $pageCount;
var $items;
var $pageNo;
var $startPos;
var $nextPageNo;
var $prevPageNo;
function Pager($infoCount, $items, $pageNo)
{
$this->infoCount=$infoCount;
$this->items =$items;
$this->pageNo=$pageNo;
$this->pageCount=$this->GetPageCount();
$this->AdjustPageNo();
$this->startPos=$this->GetStartPos();
}
function AdjustPageNo()
{
if($this->pageNo=='' || $this->pageNo < 1)
$this->pageNo=1;
if ($this->pageNo > $this->pageCount)
$this->pageNo=$this->pageCount;
}
function GoToNextPage()
{
$nextPageNo=$this->pageNo + 1;
if ($nextPageNo > $this->pageCount)
{
$this->nextPageNo=$this->pageCount;
return false;
}
$this->nextPageNo=$nextPageNo;
return true;
}
function GotoPrevPage()
{
$prevPageNo=$this->pageNo - 1;
if ($prevPageNo < 1)
{
$this->prevPageNo=1;
return false;
}
$this->prevPageNo=$prevPageNo;
return true;
}
function GetPageCount()
{
return ceil($this->infoCount / $this->items);
}
function GetStartPos()
{
return ($this->pageNo - 1) * $this->items;
}
}
?>
以上所分享的是关于php分页类,下面是编辑为你推荐的有价值的用户互动:
相关问题:php分页技术
答:这是我自己整理的一个蛮好用的分页类,里面有DEMO,你可以看一下, >>详细
相关问题:这个php分页类怎么用啊。急等
答:使用的示例代码页面上有啊: 用的时候,先连接数据库,再 select 数据,得到数据的记录总数就是上面的 $_total。$_pagesize 是你自己定义的值,比如每页显示20条记录,就设置为20。 >>详细
相关问题:这个简单的PHP分页类,该如何调用?感谢。~
答:0代表开始的下标,比如一页显示10条的话,那么第一页就是0,10,第二页就是(2-1)*10,10,第三页就是(3-1)*10,10 所以你那个0 就是写 limit($page-1)*$pagenum,$pagenum >>详细
- 评论列表(网友评论仅供网友表达个人看法,并不表明本站同意其观点或证实其描述)
-
