跳转到内容


xajax通用分页类


  • 您无法回复此主题
No replies to this topic

#1 冰力

    Administrator

  • 总版主
  • 1318 帖子数:

发表于 2007/03/16 11:34:02

function = $function; 
$this->id = $id; 
if ($thePage==0 || $thePage=="") 
{ 
$thePage = 1; 
} 
$this->pg = $thePage; 
$this->countall = $countall; 
if ($this->countall%$countlist!=0) 
{ 
$this->page=sprintf("%d",$this->countall/$countlist)+1; 
} 
else 
{ 
$this->page=$this->countall/$countlist; 
} 
if ($this->page<=10) 
{ 
for ($i=1;$i<$this->page+1;$i++) 
{ 
$this->thestr=$this->thestr.Pager::makepg($i,$this->pg); 
} 
} 
else 
{ 
if ($this->pg<=5) 
{ 
for ($i=1;$i<10;$i++) 
{ 
$this->thestr=$this->thestr.Pager::makepg($i,$this->pg); 
} 
} 
else 
{ 
if (6+$this->pg<=$this->page) 
{ 
for ($i=$this->pg-4;$i<$this->pg+6;$i++) 
{ 
$this->thestr=$this->thestr.Pager::makepg($i,$this->pg); 
} 
} 
else 
{ 
for ($i=$this->pg-4;$i<$this->page+1;$i++) 
{ 
$this->thestr=$this->thestr.Pager::makepg($i,$this->pg); 
} 
} 
} 
} 
$this->backstr = Pager::gotoback($this->pg); 
$this->nextstr = Pager::gotonext($this->pg,$this->page); 
$this->content = $this->backstr.$this->thestr.$this->nextstr." 共".$this->countall." 条,每页".$countlist."条,分".$this->page."页 当前第".$thePage."页"; 
return $this->content; 
} 

function makepg($i,$pg) 
{ 
if ($i==$pg) 
{ 
return " ".$i.""; 
} 
else 
{ 
return " ".$i.""; 
} 
} 

function gotoback($pg) 
{ 
if ($pg-1>0) 
{ 
$pg = $pg-1; 
return $this->gotoback=" 首页 上页"; 
} 
else 
{ 
return $this->gotoback=""; 
} 
} 

function gotonext($pg,$page) 
{ 
if ($pg < $page) 
{ 
$pg = $pg+1; 
return " 下页 尾页"; 
} 
else 
{ 
return ""; 
} 
} 
} 
?>