php相当简单的分页类
时间:2023-11-17 01:50:36
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;
}
}
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
Oracle 分析函数RANK(),ROW_NUMBER(),LAG()等的使用方法
如何查看python中安装库的文件位置
![](https://img.aspxhome.com/file/2023/9/85039_0s.png)
python之array赋值技巧分享
CSS网页设计时关于字体大小的设计
Django ForeignKey与数据库的FOREIGN KEY约束详解
Python学习小技巧总结
Python计算标准差之numpy.std和torch.std的区别
![](https://img.aspxhome.com/file/2023/4/94094_0s.png)
SQL Server实现分页方法介绍
![](https://img.aspxhome.com/file/2023/5/88245_0s.jpg)
手把手教你制作Google Sitemap
Python 查看文件的编码格式方法
简单PHP上传图片、删除图片实现代码
Vue.js实战之使用Vuex + axios发送请求详解
详解python中的lambda与sorted函数
详解Node.js如何开发命令行工具
python实现简单的单变量线性回归方法
![](https://img.aspxhome.com/file/2023/0/124140_0s.jpg)
SQL Server中通过reverse取某个最后一次出现的符号后面的内容(字符串反转)
NLTK的安装教程及安装错误解决方案
![](https://img.aspxhome.com/file/2023/2/68282_0s.png)
使用Python实现画一个中国地图
![](https://img.aspxhome.com/file/2023/0/131140_0s.jpg)
轻松解决AJAX的中文乱码问题
深入string理解Golang是怎样实现的
![](https://img.aspxhome.com/file/2023/1/114811_0s.jpg)