ËÑË÷   
Êղر¾Õ¾    ÉèΪÊ×Ò³    


Ê×Ò³  |  µçÓ°  |  ¶¯»­  |  Âþ»­  |  Ìùͼ  |  web±à³Ì  |  ÓÄĬЦ»°  |  °ïÖú  
РÌù    »Ø¸´Ìù×Ó    ¹²ÓÐ 0 Ìõ»ØÌù
>> web±à³Ì
  phpͨÓ÷­Ò³Àà


µ÷Ó÷½·¨

$p=new Page();

$pageSize=22;//Ò»Ò³ÏÔʾ¶àÉÙÌõ
$count=0;//×ܵÄÌõÊý

@$page=$_GET['page'];

$p->setPage($count,$page,$pageSize,"search_s=".$search_s);//×îºóÒ»¸öÊDzÎÊýÊÇ´«µÝ±äÁ¿

$curStartNum=$p->getCurStartNum();//È¡³öµ±Ç°ÌõÊý

$p->getStatus()." ".$p->getPage();//È¡³ö·­Ò³

 

Àࣺ

<?php
/*
setPage($page,$pageSize,$count,$str)³õʼÉèÖ÷­Ò³
getPage()È¡µÃ·­Ò³¹¦ÄÜ;
getPageCount()È¡µÃ×ÜÒ³Êý
getStatus()È¡µÃ״̬Çé¿ö
getCurPage()È¡µÃµ±Ç°µÄÒ³Êý
getNextPage()È¡µÃÏÂÒ»Ò³µÄÊý
getCurStartNum()È¡µÃµ±Ç°¿ªÊ¼µÄÌõÊý
getCurMaxNum()È¡µÃµ±Ç°ÏÔʾµÄÌõÊý
*/
class Page{

  //czc136@hotmail.com

  //http://www.zc36.com
 var $page=1;
 var $pageSize=1;
 var $count=1;
 var $str="-1";
 var $curStartNum=0;
 var $curMaxNum=0;
 var $nextPage=1;
 var $pageCount=1;
 function setPage($count=0,$page=1,$pageSize=1,$str=""){
  $page=intval($page);
  if($page=="" || $page==0 || $page<1)
   $page=1;
  $pageCount=$count/$pageSize;
  settype($pageCount,"int");
  $b=$count%$pageSize;
  if($b!=0)
   $pageCount++;
  $nextPage=$page+1;
  if($page>=$pageCount){
   $page=$pageCount;
   $nextPage--;
  }
  $curStartNum=0;
  $curMaxNum=0;
  if($page>1)
   $curStartNum=($page-1)*$pageSize;
  if($page*$pageSize>$count){
   $curMaxNum=$count;
  }else{
   $curMaxNum=$page*$pageSize;
  }
  //echo"<BR>".$count."|".$page."|".$pageSize."|".$str;
  $this->page=$page;
  $this->pageSize=$pageSize;
  $this->count=$count;
  $this->str=$str;
  $this->curStartNum=$curStartNum;
  $this->curMaxNum=$curMaxNum;
  $this->nextPage=$nextPage;
  $this->pageCount=$pageCount;
 }
 function getPage($type="url"){
  $tem="";
  if($type=="url"){
   if($this->str==""){
    if($this->page>1){
     $tem="<a href='?page=1'>µÚÒ»Ò³</a>&nbsp;&nbsp;";
    }else{
     $tem="µÚÒ»Ò³&nbsp;&nbsp;";
    }
    if($this->page>1){
     $tem.="<a href='?page=".($this->page-1)."'>ǰһҳ

</a>&nbsp;&nbsp;";
    }else{
     $tem.="ǰһҳ&nbsp;&nbsp;";
    }
    if($this->page<$this->pageCount){
     $tem.="<a href='?page=".$this->nextPage."'>ÏÂÒ»Ò³

</a>&nbsp;&nbsp;";
    }else{
     $tem.="ÏÂÒ»Ò³&nbsp;&nbsp;";
    }
    if($this->page!=$this->pageCount){
     $tem.="<a href='?page=".$this->pageCount."'>×îºóÒ»

Ò³</a>&nbsp;&nbsp;";
    }else{
     $tem.="×îºóÒ»Ò³&nbsp;&nbsp;";
    }
   }else{
    if($this->page>1){
     $tem="<a href='?page=1&".$this->str."'>µÚÒ»Ò³

</a>&nbsp;&nbsp;";
    }else{
     $tem="µÚÒ»Ò³&nbsp;&nbsp;";
    }
    if($this->page>1){
     $tem.="<a href='?page=".($this->page-1)."&".$this-

>str."'>ǰһҳ</a>&nbsp;&nbsp;";
    }else{
     $tem.="ǰһҳ&nbsp;&nbsp;";
    }
    if($this->page<$this->pageCount){
     $tem.="<a href='?page=".$this->nextPage."&".$this-

>str."'>ÏÂÒ»Ò³</a>&nbsp;&nbsp;";
    }else{
     $tem.="ÏÂÒ»Ò³&nbsp;&nbsp;";
    }
    if($this->page!=$this->pageCount){
     $tem.="<a href='?page=".$this->pageCount."&".$this

->str."'>×îºóÒ»Ò³</a>&nbsp;&nbsp;";
    }else{
     $tem.="×îºóÒ»Ò³&nbsp;&nbsp;";
    }
   }
  }else{//postValue
   if($this->page>1){
    $tem="<a href='#' onClick='postPage(1);return false;'>µÚÒ»

Ò³</a>&nbsp;&nbsp;";
   }else{
    $tem="µÚÒ»Ò³&nbsp;&nbsp;";
   }
   if($this->page>1){
    $tem.="<a href='#' onClick='postPage(".($this->page-

1).");return false;'>ǰһҳ</a>&nbsp;&nbsp;";
   }else{
    $tem.="ǰһҳ&nbsp;&nbsp;";
   }
   if($this->page<$this->pageCount){
    $tem.="<a href='#' onClick='postPage(".$this-

>nextPage.");return false;'>ÏÂÒ»Ò³</a>&nbsp;&nbsp;";
   }else{
    $tem.="ÏÂÒ»Ò³&nbsp;&nbsp;";
   }
   if($this->page!=$this->pageCount){
    $tem.="<a href='#' onClick='postPage(".$this-

>pageCount.");return false;'>×îºóÒ»Ò³</a>&nbsp;&nbsp;";
   }else{
    $tem.="×îºóÒ»Ò³&nbsp;&nbsp;";
   }
  }
  return $tem;
 }
 function getStatus(){
  $tem="";
  $tem=($this->curStartNum+1)."-".$this->curMaxNum."/".$this->count;
  return $tem;
 }
 function getNextPage(){
  return $this->nextPage;
 }
 function getCurPage(){
  return $this->page;
 }
 function getCurStartNum(){
  return $this->curStartNum;
 }
 function getCurMaxNum(){
  return $this->curMaxNum;
 }
 function getPageCount(){
  return $this->pageCount;
 }
 
}
?>


sky    58.62.98.*    2007-10-29 06:27:13      

http://www.zc36.com °æÈ¨ËùÓÐ  czc136#hotmail.com   QQ:834011201  ÔÁICP±¸07512307ºÅ