$this->_page = 1; else $this->_page= max(intval($_get[$getpage]), 1); $this->_page = min($this->_page, $this->_pagemax); $offset = ($this->_page - 1) * $pagesize;
$sql = 'select * from '.$table.' limit '. $offset .','. $pagesize; $this->_result = $globals['db']->query($sql); } function getrecord(){ return $globals['db']->getrecord(); } function getpagebar($url = '?', $barln = 10, $style = 1){ if($style == 1){ if($barln % 2 != 0 ){ $midder = ceil($barln / 2); $big_repair = $midder - 1 ;//当上面以进一法取整,则这里为减1,反之为加1 }else{ $midder = $big_repair = $barln / 2; } $sml_repair = $midder- 1; $this->_startpage = ($this->_page + $midder) > $this->_pagemax ? $this->_pagemax - $barln : $this->_page - $sml_repair; $this->_endpage = $this->_page _page + $big_repair;
}elseif($style == 2){ if($this->_page % $barln == 0){ $this->_startpage = $this->_page; }else{ $this->_startpage = ($this->_page > $barln)? $this->_page - ($this->_page % $barln ) : 1; } $this->_endpage = $this->_startpage + $barln - 1; } $this->_url = $url; $this->_nextpage = $this->_page + 1; $this->_prepage = $this->_page - 1; $this->_startpage = max($this->_startpage, 1);//至少从第一页开始 $this->_endpage = min($this->_endpage, $this->_pagemax);//最多只到末页 $this->_result = '当前是:'.$this->_page.'/'.$this->_pagemax.'页,共'.$this->_count.'条记录'; if ($this->_page > 1) $this->_result .= '_url.'page=1> 9_url.%20'page='.%24this->_prepage.'> 3 '; else $this->_result .= '9 3'; for($i = $this->_startpage; $i _endpage; $i++) { if ($this->_page == $i) $this->_result .= ''.$i.''; else $this->_result.= '_url.'page='.%24i.'>'.$i.''; } if ($this->_page != $this->_pagemax) { $this->_result .= '_url%20.'page='.%24this->_nextpage.'>4'; $this->_result .= '_url.'page='.%24this->_pagemax.'>:'; } else { $this->_result.= '4:'; } $this->_result.= ' _url.' onsubmit=return chickform()> '; return $this->_result; } }?>
复制代码
2、调用示例
getrecord()){echo $row[0],'
';}echo $page->getpagebar('?',8, 1); ?>
复制代码
