ado|分页
/*
+-----------------------------------------------------------------------+
| 作者:一天空一(曾用名:亿时代网络)
| 网址:www.phpwb.com www.esdwl.com
| Q Q: 31769416
| 时间:2006-05-03
|+-----------------------------------------------------------------------+
*/
class show_Pager
{
protected $_total; //记录总数
protected $pagesize; //每一页显示的记录数
public $pages; //总页数
protected $_cur_page; //当前页码
protected $offset; //记录偏移量
protected $pager_Links; //url连接
protected $pernum = 5; //页码偏移量,这里可随意更改
public function __construct($total,$pagesize,$_cur_page)
{
$this->_total=$total;
$this->pagesize=$pagesize;
$this->_offset();
$this->_pager();
$this->cur_page($_cur_page);
$this->link();
}
public function _pager()//计算总页数
{
return $this->pages = ceil($this->_total/$this->pagesize);
}
public function cur_page($_cur_page) //设置页数
{
if (isset($_cur_page))
{
$this->_cur_page=intval($_cur_page);
}
else
{
$this->_cur_page=1; //设置为第一页
}
return $this->_cur_page;
}
//数据库记录偏移量
public function _offset()
{
return $this->offset=$this->pagesize*($this->_cur_page-1);
}
//html连接的标签
public function link()
{
if ($this->_cur_page == 1 && $this->pages>1)
{
//第一页
$this->pager_Links = "首 页 | 上一页 | _cur_page+1).">下一页 | pages>尾 页";
}
elseif($this->_cur_page == $this->pages && $this->pages>1)
{
//最后一页
$this->pager_Links = "首 页 | _cur_page-1).">上一页 | 下一页 | 尾 页";
}
elseif ($this->_cur_page > 1 && $this->_cur_page pages)
{
//中间
$this->pager_Links = "首 页 | _cur_page-1).">上一页 | _cur_page+1).">下一页 | pages>尾 页";
}
return $this->pager_Links;
}
//html数字连接的标签
public function num_link()
{
$setpage = $this->_cur_page ? ceil($this->_cur_page/$this->pernum) : 1;
$pagenum = ($this->pages > $this->pernum) ? $this->pernum : $this->pages;
if ($this->_total pagesize) {
$text = '只有一页';
} else {
$text = '页数:'.$this->pages.' '.$this->pagesize.'个/页 ';
if ($this->_cur_page > 1) {
$text .= '[1]..';
}
if ($setpage > 1) {
$lastsetid = ($setpage-1)*$this->pernum;
$text .= '[';
}
if ($this->_cur_page > 1) {
$pre = $this->_cur_page-1;
$text .= '[';
}
$i = ($setpage-1)*$this->pernum;
for($j=$i; $jpages; $j++) {
$newpage = $j+1;
if ($this->_cur_page == $j+1) {
$text .= '['.($j+1).']';
} else {
$text .= '['.($j+1).']';
}
}
if ($this->_cur_page pages){
$next = $this->_cur_page+1;
$text .= '[>]';
}
if ($setpage _total) {
$nextpre = $setpage*($this->pernum+1);
if($nextprepages)
$text .= '[>>]';
}
if ($this->_cur_page pages) {
$text .= '..pages.'>['.$this->pages.']';
}
}
return $text;
}
}
//$conn,$tpl 全局变量 传入 $table是数据表 $where 是条件语句 $order 是ADSC之类的,$pager_size是每页显示数,$pager是当前页
//返回后在摸板里面可以直接使用
数字标签用
class my_Pager extends show_Pager
{
function __construct($table,$where,$order,$pager_size,$pager)
{
global $conn;
global $tpl;
$sql="SELECT * FROM `$table` $where order by $order desc";
$nums=$conn->Execute($sql)->RecordCount();
$pager=new show_Pager($nums,$pager_size,$pager);
$show=$conn->SelectLimit($sql,$pager_size,$pager->_offset())->GetAll();
$tpl->assign("numlink",$pager->num_link());//数字标签
$tpl->assign("show",$show);//显示帖子
}
}
?>
+-----------------------------------------------------------------------+
| 作者:一天空一(曾用名:亿时代网络)
| 网址:www.phpwb.com www.esdwl.com
| Q Q: 31769416
| 时间:2006-05-03
|+-----------------------------------------------------------------------+
*/
class show_Pager
{
protected $_total; //记录总数
protected $pagesize; //每一页显示的记录数
public $pages; //总页数
protected $_cur_page; //当前页码
protected $offset; //记录偏移量
protected $pager_Links; //url连接
protected $pernum = 5; //页码偏移量,这里可随意更改
public function __construct($total,$pagesize,$_cur_page)
{
$this->_total=$total;
$this->pagesize=$pagesize;
$this->_offset();
$this->_pager();
$this->cur_page($_cur_page);
$this->link();
}
public function _pager()//计算总页数
{
return $this->pages = ceil($this->_total/$this->pagesize);
}
public function cur_page($_cur_page) //设置页数
{
if (isset($_cur_page))
{
$this->_cur_page=intval($_cur_page);
}
else
{
$this->_cur_page=1; //设置为第一页
}
return $this->_cur_page;
}
//数据库记录偏移量
public function _offset()
{
return $this->offset=$this->pagesize*($this->_cur_page-1);
}
//html连接的标签
public function link()
{
if ($this->_cur_page == 1 && $this->pages>1)
{
//第一页
$this->pager_Links = "首 页 | 上一页 | _cur_page+1).">下一页 | pages>尾 页";
}
elseif($this->_cur_page == $this->pages && $this->pages>1)
{
//最后一页
$this->pager_Links = "首 页 | _cur_page-1).">上一页 | 下一页 | 尾 页";
}
elseif ($this->_cur_page > 1 && $this->_cur_page pages)
{
//中间
$this->pager_Links = "首 页 | _cur_page-1).">上一页 | _cur_page+1).">下一页 | pages>尾 页";
}
return $this->pager_Links;
}
//html数字连接的标签
public function num_link()
{
$setpage = $this->_cur_page ? ceil($this->_cur_page/$this->pernum) : 1;
$pagenum = ($this->pages > $this->pernum) ? $this->pernum : $this->pages;
if ($this->_total pagesize) {
$text = '只有一页';
} else {
$text = '页数:'.$this->pages.' '.$this->pagesize.'个/页 ';
if ($this->_cur_page > 1) {
$text .= '[1]..';
}
if ($setpage > 1) {
$lastsetid = ($setpage-1)*$this->pernum;
$text .= '[';
}
if ($this->_cur_page > 1) {
$pre = $this->_cur_page-1;
$text .= '[';
}
$i = ($setpage-1)*$this->pernum;
for($j=$i; $jpages; $j++) {
$newpage = $j+1;
if ($this->_cur_page == $j+1) {
$text .= '['.($j+1).']';
} else {
$text .= '['.($j+1).']';
}
}
if ($this->_cur_page pages){
$next = $this->_cur_page+1;
$text .= '[>]';
}
if ($setpage _total) {
$nextpre = $setpage*($this->pernum+1);
if($nextprepages)
$text .= '[>>]';
}
if ($this->_cur_page pages) {
$text .= '..pages.'>['.$this->pages.']';
}
}
return $text;
}
}
//$conn,$tpl 全局变量 传入 $table是数据表 $where 是条件语句 $order 是ADSC之类的,$pager_size是每页显示数,$pager是当前页
//返回后在摸板里面可以直接使用
数字标签用
class my_Pager extends show_Pager
{
function __construct($table,$where,$order,$pager_size,$pager)
{
global $conn;
global $tpl;
$sql="SELECT * FROM `$table` $where order by $order desc";
$nums=$conn->Execute($sql)->RecordCount();
$pager=new show_Pager($nums,$pager_size,$pager);
$show=$conn->SelectLimit($sql,$pager_size,$pager->_offset())->GetAll();
$tpl->assign("numlink",$pager->num_link());//数字标签
$tpl->assign("show",$show);//显示帖子
}
}
?>
声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn

热AI工具

Undresser.AI Undress
人工智能驱动的应用程序,用于创建逼真的裸体照片

AI Clothes Remover
用于从照片中去除衣服的在线人工智能工具。

Undress AI Tool
免费脱衣服图片

Clothoff.io
AI脱衣机

Video Face Swap
使用我们完全免费的人工智能换脸工具轻松在任何视频中换脸!

热门文章
刺客信条阴影:贝壳谜语解决方案
3 周前ByDDD
Windows 11 KB5054979中的新功能以及如何解决更新问题
3 周前ByDDD
在哪里可以找到原子中的起重机控制钥匙卡
3 周前ByDDD
<🎜>:死铁路 - 如何完成所有挑战
4 周前ByDDD
Atomfall指南:项目位置,任务指南和技巧
1 个月前ByDDD

热工具

SecLists
SecLists是最终安全测试人员的伙伴。它是一个包含各种类型列表的集合,这些列表在安全评估过程中经常使用,都在一个地方。SecLists通过方便地提供安全测试人员可能需要的所有列表,帮助提高安全测试的效率和生产力。列表类型包括用户名、密码、URL、模糊测试有效载荷、敏感数据模式、Web shell等等。测试人员只需将此存储库拉到新的测试机上,他就可以访问到所需的每种类型的列表。

Dreamweaver CS6
视觉化网页开发工具

DVWA
Damn Vulnerable Web App (DVWA) 是一个PHP/MySQL的Web应用程序,非常容易受到攻击。它的主要目标是成为安全专业人员在合法环境中测试自己的技能和工具的辅助工具,帮助Web开发人员更好地理解保护Web应用程序的过程,并帮助教师/学生在课堂环境中教授/学习Web应用程序安全。DVWA的目标是通过简单直接的界面练习一些最常见的Web漏洞,难度各不相同。请注意,该软件中

SublimeText3 英文版
推荐:为Win版本,支持代码提示!

EditPlus 中文破解版
体积小,语法高亮,不支持代码提示功能