动网论坛,站长建站首选,国内使用量最多的论坛软件 动网论坛官方技术讨论区 站长工具 申请属于您自己的免费论坛
首页 | 新闻资讯 | 网站运营 | 网络编程 | 数据库 | 服务器 | 网页设计 | 图像媒体 | 网络应用 | 搜索优化 | 资源下载 | 动网主机 | DVBOX
    本站内  互联网 ASP论坛  ASP.Net论坛  PHP论坛
  
   PHP → 阅读文章

 分页类

作者来源: 
阅读 1277 人次 , 2006-3-29 4:08:00 


<?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");
}
/**
* 分页类
* purpose
* 分页
*
* @author : whxbb(whxbb@21cn.com)
* @version : 0.1
* @date : 2001/8/2
*/
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;
}
}
?>

 本文Tags分页  
 收藏本文  打印本文  论坛讨论  关闭窗口
· 上一篇:封装对文章的各种操作(插入数据库、从数据库取出等等)
· 下一篇:插入实例
· Solid 数据库链接函数库
· PHP:MVC迷思
· PHP如何读取COOKIES
· PHP新手上路(二)
· PHP中的日期处理


关于本站 | 联系我们 | 业务合作 | 客户案例 | 诚聘英才 | 广告合作 | 收藏本站
海口动网先锋网络科技有限公司版权所有
Copyright © 2000 - 2006 Cndw.Com
中华人民共和国电信与信息服务业务经营许可证编号 琼 ICP 020077