强大php 分页代码类
本教程为各位朋友提供一款类型discuz论坛风格的分页代码了,我们把这段代码写成了一个函数哦,下面来看看吧。
本教程为各位朋友提供一款类型discuz论坛风格的分页代码了,我们把这段代码写成了一个函数哦,下面来看看吧。
//分页当页面数
function getPage($page,$pageSize){
$this->getRowsCount();
$this->getPageCount($pageSize);
//print $this->pageCount;
if(($page =="") || ($page<"1") || (!ereg("[0-9]+",$page))){
$this->notePage = "1";
}else if($page>$this->pageCount){
$this->notePage = $this->pageCount;
}else{
$this->notePage = $page;
}
return $this->notePage;
}
//取得记录总数
function getRowsCount(){
$this->getRes($this->sql_number);
$row = $this->getRows();
$this->number = $row[0];
return $this->number;
}
//取得页面数量
function getPageCount($pageSize){
$this->pageCount = ceil($this->number/$pageSize);
return $this->pageCount;
}
//分页代码
function getPageContent($page,http://pic2.phprm.com/2013/09/05/http://pic2.phprm.com/2013/09/05/$url,$page.jpg.jpgSize){
if($page=="1"){
$view.=" [首页]";
$view.=" [上一页]";
}else{
$view.=" <a href=".$url."page=1>[首页]</a>";
$view.=" <a href=".$url."page=".($page-1) ." >[上一页]</a>";
}
if($page<$this->pageCount){
$view.=" <a href=".$url."page=".($page+1) ." >[下一页]</a>";
$view.=" <a href=".$url."page=".$this->pageCount." >[尾页]</a>";
}else{
$view.=" [下一页]";
$view.=" [尾页]";
}
return $view." 当前第".$page."页/共".$this->pageCount."页 ".$this->number."条记录"." 前往第 ".$this->getUrl($url,$page);
}
//分页转至页面
function getUrl($url,$page){
$go ="<input type="text" size="2" name="page" value="".$page."" class="but01"/> 页
<input type="button" value="GO" onclick="location.href=".$url."page=+page.value"/>";
return $go;
}
//跳转页面
function refUrl(http://pic2.phprm.com/2013/09/05/$url,$speak.jpg){
print("<script language=javascript>");
print("alert(".$speak.");");
print("location.href=".$url.";");
print("</script>");
}
本文地址:http://www.phprm.com/frame/php1004937.html
转载随意,但请附上文章地址:-)