首页 | 编程语言 | 网站建设 | 游戏天堂 | 冲浪宝典 | 网络安全 | 操作系统 | 软件时空 | 硬件指南 | 病毒相关 | IT 认证
软讯网络 > 网站建设 > PHP > 分页类
【标  题】:分页类
【关键字】:分页
【来  源】:网络

分页类


<?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;
    }
}
?>

Win32下具体实现Apache的用户验证:【上一篇】
xzn_html_tree(1.0) 可折叠大纲:【下一篇】
【相关文章】
  • 一个分页导航类
  • 一个分页导航类示例
  • PHP中记录分页显示实例
  • 非递归法实现论坛树型结构及分页
  • 一种高效的分页机制
  • 一个用PHP+MYSQL实现论坛里的分级+分页显示的例程
  • Php+MySql分页机制两种方案的比较测试
  • 关于分页机制
  • 用PHP3实现MySQL数据的分页显示
  • php中分页显示文章标题
  • 【随机文章】
  • CNSCN AWK使用总结
  • Casl汇编语言辅导(2)
  • 一起来视频聊天!Fireworks绘制逼真摄像头
  • 使用异步接口的IP和SLIP举例
  • What means make "TARGET=12345" goal1 goal2
  • 对OPENCMS汉化的总结,超准确
  • 网页制作三剑客8的彩蛋
  • C#与JAVA之比较(4)
  • [翻译]-Windows CE 程序设计 (3rd 版)--5.2 公共控件(十)
  • 一个中年职场人对应届生谈招聘
  • 【相关评论】
    没有相关评论
    【发表评论】
    姓名:
    邮件:
    随机码*
    评论*
          
    |  首 页  |  版权声明  |  联系我们   |  网站地图  |
    CopyRight © 2004-2007 软讯网络 All Rigths Reserved.