PHP分页类
发布:smiling 来源: PHP粉丝网 添加日期:2013-12-10 10:46:56 浏览: 评论:
- <?php
-
- 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多功能图片处理类(2013-11-11)
- ·PHP 生成缩略图的类(2013-11-13)
- ·一个分页显示类(2013-11-13)
- ·分享的一个分页类(2013-11-13)
- ·简单的php分页类(2013-11-14)
- ·一个功能比较高的分页类(for PHP5.x)(2013-11-28)
- ·phpword中文字符乱码解决办法(2013-12-05)
- ·一个比较完善的购物车类(2013-12-08)
- ·php面象对象数据库操作类(2013-12-09)
- ·PHP顶层类(2013-12-10)
- ·PHP静态文件生成类(2013-12-10)
- ·非常简单的日历类(2013-12-11)
- ·php数字分页类的代码(2013-12-23)
- ·PHP货币换算程序代码(2013-12-27)
- ·实现多文件上传php类(2014-01-03)
- ·php树形结构数据存取实例类(2014-01-07)