<script language= "JavaScript" >
function Createxmlhttp () {
if (window. ActiveXObject) {
return new ActiveXObject ("Microsoft.XMLHTTP");
}
else if (window. XMLHttpRequest) {
return new XMLHttpRequest ();
}
}
function Pager () {
var that=this;
This.link=function (URL) {
That.xmlhttp = Createxmlhttp ();
That.xmlHttp.onreadystatechange = that.receive;
That.xmlHttp.open ("Get", url, True);
That.xmlHttp.send (NULL);
}
this.receive=function () {
if ( That.xmlHttp.readyState = = 4)) {
if ( That.xmlHttp.status = {
that.reaction (That.xmlHttp.responseXML);
}else{
That.recover ();
}
}
}
}
</script>
<body>
<div id= ' page_content ' ></div>
< Div id= ' page_bar ' ></div>
<script language= ' JavaScript '
var a = new Pager ();
var pages = 0;
A.recover = function () {
Go = function (u) {
Go = function () {
};
A.link (U);
};
};
A.reaction = function (XML) {
document.getElementById (' page_content '). InnerHTML = Xml.getelementsbytagname (' content ') [0].childnodes[0]. NodeValue;
if (Xml.getelementsbytagname (' count ') [0].childnodes[0].nodevalue!= pages) {
s = ' <table><tr> ';
for (i = 1; I <= xml.getelementsbytagname (' count ') [0].childnodes[0].nodevalue; i++)
{
if (i = = xml.getelementsbytagname (' current ') [0].childnodes[0].nodevalue]
s + + ' <td><b> ' + i + ' </b></td> ';
Else
s + + ' <td><a href= ' Javascript:go (\ ' page.php?page= ' + i + ') ' > ' + i + ' </a></td> ';
}
s + + ' </tr></table> ';
document.getElementById (' Page_bar '). InnerHTML = S;
}
A.recover ();
}
A.link (' page.php ');
</script>
</body>
page.php code.
<?php
Class Class_page
{
private $record _count, $perpage;
Private $page _count, $page _current;
function __construct ($perpage, $record _count, $page _current)
{
$this->perpage = $perpage;
$this->record_count = $record _count;
$this->page_count = ($record _count = 0)? 1:ceil ($record _count/$pe RPage);
$this->page_current = ($page _current > $this->page_count)? 1 : $page _current;
}
function __get ($name)
{
Switch ($name)
{
case ' Page_count ':
return $this->page_count;
case ' page_current ':
return $this->page_current;
case ' Record_start ':
return ($this->page_current-1) * $this->perpage;
}
}
}
Header (' Content-type:text/xml charset=gbk ');
$page = new Class_page (is_numeric, $_get[' page ')? $_get[' page ': 1);
Echo ' <?xml version= ' 1.0 '?> ';
Echo ' <page> ';
Echo ' <count> '. $page->page_count. ' </count> ';
Echo ' <current> '. $page->page_current. ' </current> ';
Echo ' <content> '. Pow ($page->page_current, 2). ' </content> ';
Echo ' </page> ';
?