超强分页类
时间:2006-01-16 来源:wleige
PHP代码:--------------------------------------------------------------------------------
_currentPage = max((int)@$_GET['pageId'], 1); //当前的页序号
$this->_perPage = $_perPage; //每一页记录数
$this->_totalItems = $_totalItems;//总记录数
$this->_totalPages = ceil($this->_totalItems / $this->_perPage); //总页数
$this->_linkData = $_linkData; //传递的变量
$this->_listStart = ($this->_currentPage - 1) * $this->_perPage + 1; //当前头条记录ID
$this->_listEnd = ($this->_currentPage != $this->_totalPages) ? $this->_currentPage * $this->_perPage : $this->_totalItems;//当前最后条记录ID
$this->_startId = $this->_listStart -1; //从数据库读出的启始id
}
function startId(){ //从数据库读出的启始id
return $this->_startId;
}
function totalItems(){ //总记录数
return $this->_totalItems;
}
function totalPages(){ //总页数
return $this->_totalPages;
}
function listStart(){ //当前头条记录ID
return $this->_listStart;
}
function listEnd(){ //当前最后条记录ID
return $this->_listEnd;
}
function currentPage(){ //当前页
return $this->_currentPage;
}
function pageStart(){ //第一页
return $this ->_pageStart = "_linkData)."&pageId=1>9";
}
function pageEnd(){ //最后页
return $this ->_pageEnd = "_linkData)."&pageId=".$this->_totalPages.">:";
}
function upPage(){ //上一页
if($this->_currentPage > 1 and $this->_currentPage _totalPages){
$up = $this->_currentPage-1;
return $this->_upPage = "_linkData)."&pageId=".$up.">7";
}
}
function downPage(){ //下一页
$down = $this->_currentPage+1;
if($this->_currentPage _totalPages)
return $this->_downPage = "_linkData)."&pageId=".$down.">8";
}
function listPage(){ //循环显示当前分页列表
if($this->_currentPage _currentPage != ""){
$start = 1;
if($this->_totalPages _totalPages;
else $end = 10;
}elseif(($this->_currentPage + 5) > $this->_totalPages){
$start = $this->_currentPage - 5;
$end = $this->_totalPages;
}else{
$start = $this->_currentPage - 4;
$end = $this->_currentPage +5;
}
for($i = $start; $i _listPage .= "_linkData)."&pageId=".$i.">".$i." ";
}
return $this->_listPage;
}
function jumpPage(){ //跳转
$this->_jumpPage = "跳转 _linkData)."&pageId='+this.value;\">"; //页面跳转
for($i = 1; $i _totalPages; $i++){
if($i == $this->_currentPage) $selected = "selected";
$this->_jumpPage .= "$i";
unset($selected);
}
return $this->_jumpPage .= " 页";
}
}
///范例
$totalItems = 1100; //总记录
$page = new Pager($totalItems,10,"?a=b&c=6");
for($i = $page->startId(); $i startId() + 10; $i++){
$data[] = array($i,$i+1);
}
echo "当前开始ID:".$listStart = $page->listStart();echo "
";
echo "当前结束ID:".$listEnd = $page->listEnd();echo "
";
echo "第一页:".$pageStart = $page->pageStart();echo "
";
echo "最后页:".$pageEnd = $page->pageEnd();echo "
";
echo "上一页:".$upPage = $page->upPage();echo "
";
echo "下一页:".$downPage = $page->downPage();echo "
";
echo "列表显示:".$listPage = $page->listPage();echo "
";
echo "跳转页:".$jumpPage = $page->jumpPage();echo "
";
//print_r($data);
echo "
";
print "NN+1";
foreach ($data as $key0 => $value0) {
print "";
foreach ($value0 as $key1 => $value1) {
print "$value1";
}
print "";
}
print "";
?>
_currentPage = max((int)@$_GET['pageId'], 1); //当前的页序号
$this->_perPage = $_perPage; //每一页记录数
$this->_totalItems = $_totalItems;//总记录数
$this->_totalPages = ceil($this->_totalItems / $this->_perPage); //总页数
$this->_linkData = $_linkData; //传递的变量
$this->_listStart = ($this->_currentPage - 1) * $this->_perPage + 1; //当前头条记录ID
$this->_listEnd = ($this->_currentPage != $this->_totalPages) ? $this->_currentPage * $this->_perPage : $this->_totalItems;//当前最后条记录ID
$this->_startId = $this->_listStart -1; //从数据库读出的启始id
}
function startId(){ //从数据库读出的启始id
return $this->_startId;
}
function totalItems(){ //总记录数
return $this->_totalItems;
}
function totalPages(){ //总页数
return $this->_totalPages;
}
function listStart(){ //当前头条记录ID
return $this->_listStart;
}
function listEnd(){ //当前最后条记录ID
return $this->_listEnd;
}
function currentPage(){ //当前页
return $this->_currentPage;
}
function pageStart(){ //第一页
return $this ->_pageStart = "_linkData)."&pageId=1>9";
}
function pageEnd(){ //最后页
return $this ->_pageEnd = "_linkData)."&pageId=".$this->_totalPages.">:";
}
function upPage(){ //上一页
if($this->_currentPage > 1 and $this->_currentPage _totalPages){
$up = $this->_currentPage-1;
return $this->_upPage = "_linkData)."&pageId=".$up.">7";
}
}
function downPage(){ //下一页
$down = $this->_currentPage+1;
if($this->_currentPage _totalPages)
return $this->_downPage = "_linkData)."&pageId=".$down.">8";
}
function listPage(){ //循环显示当前分页列表
if($this->_currentPage _currentPage != ""){
$start = 1;
if($this->_totalPages _totalPages;
else $end = 10;
}elseif(($this->_currentPage + 5) > $this->_totalPages){
$start = $this->_currentPage - 5;
$end = $this->_totalPages;
}else{
$start = $this->_currentPage - 4;
$end = $this->_currentPage +5;
}
for($i = $start; $i _listPage .= "_linkData)."&pageId=".$i.">".$i." ";
}
return $this->_listPage;
}
function jumpPage(){ //跳转
$this->_jumpPage = "跳转 _linkData)."&pageId='+this.value;\">"; //页面跳转
for($i = 1; $i _totalPages; $i++){
if($i == $this->_currentPage) $selected = "selected";
$this->_jumpPage .= "$i";
unset($selected);
}
return $this->_jumpPage .= " 页";
}
}
///范例
$totalItems = 1100; //总记录
$page = new Pager($totalItems,10,"?a=b&c=6");
for($i = $page->startId(); $i startId() + 10; $i++){
$data[] = array($i,$i+1);
}
echo "当前开始ID:".$listStart = $page->listStart();echo "
";
echo "当前结束ID:".$listEnd = $page->listEnd();echo "
";
echo "第一页:".$pageStart = $page->pageStart();echo "
";
echo "最后页:".$pageEnd = $page->pageEnd();echo "
";
echo "上一页:".$upPage = $page->upPage();echo "
";
echo "下一页:".$downPage = $page->downPage();echo "
";
echo "列表显示:".$listPage = $page->listPage();echo "
";
echo "跳转页:".$jumpPage = $page->jumpPage();echo "
";
//print_r($data);
echo "
";
print "NN+1";
foreach ($data as $key0 => $value0) {
print "";
foreach ($value0 as $key1 => $value1) {
print "$value1";
}
print "";
}
print "";
?>
相关阅读 更多 +