php相当简单的分页类

yipeiwu_com6年前PHP代码库
class Helper_Page{

/** 总信息数 */
var $infoCount;
/** 总页数 */
var $pageCount;
/** 每页显示条数 */
var $items;
/** 当前页码 */
var $pageNo;
/** 查询的起始位置 */
var $startPos;
/** 下一页 */
var $nextPageNo;
/** 上一页 */
var $prevPageNo;

function Helper_Page($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;
}
}

相关文章

海河写的 Discuz论坛帖子调用js的php代码

调用代码 <script language="javascript" src="js_bbs.php?fid=1"></script> js_...

Thinkphp事务操作实例(推荐)

实例如下: //开启mysql事务操作 $model = M(); $model->startTrans(); $flag=false; $deal1 = M('ppdd')-...

PHP常见过waf webshell以及最简单的检测方法

PHP常见过waf webshell以及最简单的检测方法

前言 之前在Webshell查杀的新思路中留了一个坑 ️,当时没有找到具体找到全部变量的方法,后来通过学习找到了个打印全部量的方法,并再次学习了下PHP webshell绕...

PHP数组对象与Json转换操作实例分析

本文实例讲述了PHP数组对象与Json转换操作。分享给大家供大家参考,具体如下:代码<?php //数组转对象 function arrayToObject($e){  ...

关于Appserv无法打开localhost问题的解决方法

安装了Appserv时,无法打开http://localhost或是http://127.0.0.1 在端口没有被占的情况下(本来我就没安装IIS),只要启动下D:\AppServ\Ap...