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