欢迎光临
我们一直在努力

五 分页类-PHP教程,PHP应用

建站超值云服务器,限时71元/月

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

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 五 分页类-PHP教程,PHP应用
分享到: 更多 (0)

相关推荐

  • 暂无文章