【编者按】网学网Ajax频道为大家收集整理了“php ajax无刷新分页,支持id定位“提供大家参考,希望对大家有所帮助!
<?php
Header("Content-Type:text/html; charset=utf-8");
function AjaxPage($Total,$ListNub,$CurrentPage,$Url,$AjaxAction,$HalfPer='''',$ViewId='''')
{
//计算总页数
$totalPage = @ceil($Total/$ListNub);
$total=$totalPage-1;
$re="";
//echo $CurrentPage;
$re .= ( $CurrentPage > 0 )
?
"<td><a
href=\"javascript:$AjaxAction(''$Url=0'',''$ViewId'')\"\">首页</a></td>\n<td><a
href=\"javascript:$AjaxAction(''".$Url."=".($CurrentPage-1)."'',''$ViewId'')\"\"></a></td>\n"
:
"<td>首页</td>\n<td></td>\n";
for ( $i =
$CurrentPage - $HalfPer,$i > 0 || $i = 0 , $j =
$CurrentPage + $HalfPer, $j < $totalPage || $j = $totalPage;$i < $j ;$i++
)
{
$re .= $i == $CurrentPage
?
"<td><b class=currentPage>[" . ( $i + 1 ) .
"]</b></td>\n"
: "<td><a
href=\"javascript:$AjaxAction(''$Url=$i'',''$ViewId'')\">" . ( $i + 1 ) .
"</a></td>\n";
}
$re .= ( $CurrentPage < $total
)
? "<td><a
href=\"javascript:$AjaxAction(''".$Url."=".($CurrentPage+1)."'',''$ViewId'')\"\"></a></td>\n<td><a
href=\"javascript:$AjaxAction(''".$Url."=".($total)."'',''$ViewId'')\"\">尾页</a>\n</td>"
:
"<td></td>\n<td>尾页</td>\n";
$re="<table
style=text-align:center><tr>$re</tr></table>";
return
$re;
}
//总页数,传递的页面变量-当前页 url地址 前后各多少页
$page =