php专区

 首页 > php专区 > PHP应用 > php类库 > PHP分页类 - php类库

PHP分页类 - php类库

分享到:
【字体:大 中 小】
导读:
          ?php 禁止直接访问该页面if(basename($HTTP_SERVER_VARS[ 39;PHP_SELF 39;])==pager class php){ header(HTTP 1 0404NotFound);...

PHP分页类

  1. // 禁止直接访问该页面 
  2. if (basename($HTTP_SERVER_VARS['PHP_SELF']) == "pager.class.php") { 
  3.    header("HTTP/1.0 404 Not Found"); 
  4. } 
  5.  
  6. class Pager 
  7. { 
  8.    /** 总信息数 */ 
  9.    var $infoCount; 
  10.    /** 总页数 */ 
  11.    var $pageCount; 
  12.    /** 每页显示条数 */ 
  13.    var $items; 
  14.    /** 当前页码 */ 
  15.    var $pageNo; 
  16.    /** 查询的起始位置 */ 
  17.    var $startPos; 
  18.    var $nextPageNo; 
  19.    var $prevPageNo; 
  20.   
  21.    function Pager($infoCount, $items, $pageNo) 
  22.    { 
  23.      $this->infoCount = $infoCount; 
  24.      $this->items   = $items; 
  25.      $this->pageNo  = $pageNo; 
  26.      $this->pageCount = $this->GetPageCount(); 
  27.      $this->AdjustPageNo(); 
  28.      $this->startPos = $this->GetStartPos(); 
  29.    } 
  30.    function AdjustPageNo() 
  31.    { 
  32.      if($this->pageNo == '' || $this->pageNo < 1) 
  33.        $this->pageNo = 1; 
  34.      if ($this->pageNo > $this->pageCount) 
  35.        $this->pageNo = $this->pageCount; 
  36.    } 
  37.    /** 
  38.    * 下一页 
  39.    */ 
  40.    function GoToNextPage() 
  41.    { 
  42.      $nextPageNo = $this->pageNo 1; 
  43.      if ($nextPageNo > $this->pageCount) 
  44.      { 
  45.        $this->nextPageNo = $this->pageCount; 
  46.        return false; 
  47.      } 
  48.      $this->nextPageNo = $nextPageNo; 
  49.      return true; 
  50.    } 
  51.    /** 
  52.    * 上一页 
  53.    */ 
  54.    function GotoPrevPage() 
  55.    { 
  56.      $prevPageNo = $this->pageNo - 1; 
  57.      if ($prevPageNo < 1) 
  58.      { 
  59.        $this->prevPageNo = 1; 
  60.        return false; 
  61.      } 
  62.      $this->prevPageNo = $prevPageNo; 
  63.      return true; 
  64.    } 
  65.    function GetPageCount() 
  66.    { 
  67.      return ceil($this->infoCount / $this->items); 
  68.    } 
  69.    function GetStartPos() 
  70.    { 
  71.      return ($this->pageNo - 1) * $this->items; 
  72.    } 
  73. } 
  74. ?> 
分享到:
php分页程序paginator程序代码 - php类库
php分页程序paginator程序代码
非常简单的日历类 - php类库
非常简单的日历类 date_default_timezone_set("etc/gmt-8");  class calendar{  var $t = array();  var $datesofmonth = array('1'=>'31','2'=>'28','3'=>'31','4'=>'30','5'=>'31','6'=>'30','7'=>'31','8'=>'31','9'=>'30','10'=>'31','11'=>'30','12'=>'31');  va...
  •         php迷,一个php技术的分享社区,专属您自己的技术摘抄本、收藏夹。
  • 在这里……