作者:我的生活我做主哦耶_266 | 来源:互联网 | 2018-07-17 03:59
提供一款超好的php 文件分页代码 上一页 下一页哦,这一款是dedecms的生成页面时的分页程序代码。
function GetPagebreakDM($totalPage,$nowPage,$aid)
{
global $cfg_rewrite;
if($totalPage==1)
{
return "";
}
$PageList = "
共".$totalPage."页: ";
$nPage = $nowPage-1;
$lPage = $nowPage+1;
if($nowPage==1)
{
$PageList.="
上一页";
}
else
{
if($nPage==1)
{
$PageList.="
上一页";
if($cfg_rewrite == 'Y')
{
$PageList = preg_replace("/.php?aid=(d+)/i",'-\1-1.html',$PageList);
}
}
else
{
$PageList.="
上一页";
if($cfg_rewrite == 'Y')
{
$PageList = str_replace(".php?aid=","-",$PageList);
$PageList = preg_replace("/&pageno=(d+)/i",'-\1.html',$PageList);
}
}
}
for($i=1;$i<=$totalPage;$i++)
{
if($i==1)
{
if($nowPage!=1)
{
$PageList.="
1";
if($cfg_rewrite == 'Y')
{
$PageList = preg_replace("/.php?aid=(d+)/i",'-\1-1.html',$PageList);
}
}
else
{
$PageList.="
1";
}
}
else
{
$n = $i;
if($nowPage!=$i)
{
$PageList.="
".$n."";
if($cfg_rewrite == 'Y')
{
$PageList = str_replace(".php?aid=","-",$PageList);
$PageList = preg_replace("/&pageno=(d+)/i",'-\1.html',$PageList);
}
}
else
{
$PageList.="
{$n}";
}
}
}
if($lPage <= $totalPage)
{
$PageList.="
下一页";
if($cfg_rewrite == 'Y')
{
$PageList = str_replace(".php?aid=","-",$PageList);
$PageList = preg_replace("/&pageno=(d+)/i",'-\1.html',$PageList);
}
}
else
{
$PageList.= "
下一页";
}
return $PageList;
}