<?php
Header("Content-Type:text/html; charset=utf-8");
// AK QQ:42220796
//Total number of items on a single page. URL address after clicking on the current page. Get the applied js function. Display several displayed addresses.
function AjaxPage($Total,$ListNub,$CurrentPage,$Url,$AjaxAction,$HalfPer='',$ViewId='')
{
//Calculate the total number of pages
$totalPage = @ceil($Total/$ListNub);
$total=$totalPage-1;
$re="";
//echo $CurrentPage;
$re .= ( $CurrentPage > 0 )
?
"<td><a
href="javascript:$AjaxAction('$Url=0','$ViewId')"">Homepage</a></td>n<td><a
href="javascript:$AjaxAction('".$Url."=".($CurrentPage-1)."','$ViewId')"">Previous page</a></td> n"
:
"<td>Home page</td>n<td>Previous page</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')"">Next page</a></td> n<td><a
href="javascript:$AjaxAction('".$Url."=".($total)."','$ViewId')"">Last page</a>n</td>"
:
"<td>Next page</td>n<td>Last page</td>n";
$re="<table
style=text-align:center><tr>$re</tr></table>";
return
$re;
}
//Total number of pages, passed page variables - how many pages before and after the current page url address
$page = $_GET['page'];
//echo
page('10',$page,'index.php?page','2');
?>
<div id="nike">
<?php
echo
AjaxPage(200,20,$page,'rand.php?page','ajaxaction','2','nike');
?>
</div>
<script type="text/javascript" language="javascript">
var
http_request = false;
function send_request(url,htmlid) {
http_request=
false;
if (window.XMLHttpRequest) {
http_request = new
XMLHttpRequest();
if (http_request.overrideMimeType)
{
http_request.overrideMimeType('text/xml');
}
}
else if (window.ActiveXObject) {
try
{
http_request = new
ActiveXObject("Msxml2.XMLHTTP");
} catch (e)
{
try {
http_request = new
ActiveXObject("Microsoft.XMLHTTP");
} catch (e)
{}
}
}
if (!http_request)
{
alert('Cannot create XMLHttpRequest object!');
return
false;
}
http_request.onreadystatechange = function
(){likeakak(htmlid);}//processRequest(htmlid)
http_request.open('GET',
url, true);
http_request.send(null);
}
//Process return information
function processRequest(htmlid) {
if
(http_request.readyState == 1)
{
document.getElementById(htmlid).innerHTML="Downloading...";
}
if
(http_request.readyState == 4) {
if (http_request.status == 200)
{
document.getElementById(htmlid).innerHTML=http_request.responseText;
}
else
{
alert('Request exception');
}
}
}
//Process return information
function
likeakak(htmlid)
{
if (http_request.readyState == 1)
{
document.getElementById(htmlid).innerHTML="Downloading...";
}
if
(http_request.readyState == 4) {
if (http_request.status == 200)
{
document.getElementById(htmlid).innerHTML=http_request.responseText;
}
else
{
alert('Request exception');
}
}
}
function
ajaxaction(url,viewid)
{
send_request(url,viewid);
}
//Customized calling function
function elist(id)
{
var inputarray = new
Array();
inputarray[1] = 'aaa';
inputarray[2] =
'bbb';
inputarray[3] = 'ccc';
inputarray[4] =
'ddd';
inputarray[5] = 'eee';
send_request('ajax.php?do=ajax&sort='+id,inputarray[id]);
}
</script>