这是一款比较经典的php分页代码,利用了程序模板,页面分离的方式来做这个文件分页功能,实在是太牛了,实例代码如下.
page.class.php:
-
class page{
-
-
var $currentpage;
-
var $leftoffset;
-
var $rightoffset;
-
-
var $totalpage;
-
var $recordcount;
-
var $pagesize;
-
-
var $pageurl;
-
var $hypelink;
-
-
var $template;
-
var $tpl;
-
var $tagitems=array();
-
var $tagvalues=array();
-
-
var $sqlquery;
-
-
-
function page($currentpage=1,$pagesize=5,$leftoffset=2,$rightoffset=7,$pageurl="?page="){
-
echo "分页类开始";
-
$this->currentpage=ceil(abs(@$currentpage+0));
-
(emptyempty($this->currentpage))?$this->currentpage=1:$this->currentpage=$this->currentpage;
-
$this->pagesize=ceil(abs(@$pagesize+0));
-
(emptyempty($this->pagesize))?$this->pagesize=5:$this->pagesize=$this->pagesize;
-
$this->leftoffset=ceil(abs(@$leftoffset+0));
-
(emptyempty($this->leftoffset))?$this->leftoffset=2:$this->leftoffset=$this->leftoffset;
-
$this->rightoffset=ceil(abs(@$rightoffset+0));
-
(emptyempty($this->rightoffset))?$this->rightoffset=7:$this->rightoffset=$this->rightoffset;
-
$this->pageurl=$pageurl;
-
-
$this->setdefaulttagvalue();
-
}
-
-
-
-
function getrecordcount($sql,$conn){
-
$query=@mysql教程_query($sql,$conn);
-