php仿ZOL分頁(yè)類(lèi)代碼
更新時(shí)間:2008年10月02日 01:11:11 作者:
模板zol網(wǎng)站的分頁(yè)效果代碼,效果如下圖所示
復(fù)制代碼 代碼如下:
<?php
/**
* 功能:分頁(yè)類(lèi)
* 作者:phpox
* 時(shí)間:Sat Jul 14 18:15:02 CST 2007
*/
defined('PHPOX') or die(header("HTTP/1.1 403 Not Forbidden"));
class page{
public $infocount;
public $pagecount;
public $items;
public $pageno;
public $start;
public $next;
public $prev;
public $maxpages;
public function __construct($infocount,$items,$pageno){
$this->infocount = $infocount;
$this->items = $items;
$this->pageno = $pageno;
$this->pagecount = $this->getpagecount();
$this->justpageno();
$this->start = $this->getstart();
$this->gotoprev();
$this->gotonext();
}
private function justpageno(){
if (emptyempty($this->pageno) || $this->pageno < 1){
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount){
$this->pageno = $this->pagecount;
}
}
private function gotonext(){
$next = $this->pageno + 1;
if ($next > $this->pagecount){
$this->next = $this->pagecount;
}else {
$this->next = $next;
}
}
private function gotoprev(){
$prev = $this->pageno -1;
if ($prev < 1){
$this->prev = 1;
}else {
$this->prev = $prev;
}
}
private function getpagecount(){
return ceil($this->infocount / $this->items);
}
private function getstart(){
if ($this->pageno <= 1){
return 0;
}else {
return ($this->pageno - 1) * $this->items;
}
}
/**
* 樣式0(php)
*/
public function showpage($ctlname,$actname,$args = null){
if ($args !== null){
if (is_array($args)){
$str = '&'.encode_url_args($args);
}
}
$out = '';
$out .= "每頁(yè)顯示{$this->items}條信息 ";
$out .= "當(dāng)前頁(yè)<strong><font color=\"#FF0000\">{$this->pageno}</font>/{$this->pagecount}</strong> ";
$out .= "共有{$this->infocount}條信息 ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p=1$str'>首頁(yè)</a> ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p={$this->prev}$str'>上一頁(yè)</a> ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p={$this->next}$str'>下一頁(yè)</a> ";
$out .= "<a href='?ctl={$ctlname}&act={$actname}&p={$this->pagecount}$str'>尾頁(yè)</a> ";
$out .= "跳轉(zhuǎn)到:";
$out .= "<select id=\"page\" name=\"page\" onchange=\"javascript:window.location='?ctl={$ctlname}&act={$actname}$str&p='+this.options[this.selectedIndex].value;\">\n";
$out .= " <option value=\"1\">請(qǐng)選擇</option>\n";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value=\"$i\">第{$i}頁(yè)</option>\n";
}
$out .= "</select>\n";
return $out;
}
/**
* 樣式1(html)
*/
function htmlshowpage($path,$list,$film){
$out = '';
$out .= "每頁(yè)顯示{$this->items}條信息 ";
$out .= "當(dāng)前頁(yè)<strong><font color=\"#FF0000\">{$this->pageno}</font>/{$this->pagecount}</strong> ";
$out .= "共有{$this->infocount}條信息 ";
$out .= "<a href='{$path}$list/{$film}_1.html'>首頁(yè)</a> ";
$out .= "<a href='{$path}$list/{$film}_{$this->prev}.html'>上一頁(yè)</a> ";
$out .= "<a href='{$path}$list/{$film}_{$this->next}.html'>下一頁(yè)</a> ";
$out .= "<a href='{$path}$list/{$film}_{$this->pagecount}.html'>尾頁(yè)</a> ";
$out .= "跳轉(zhuǎn)到:";
$out .= "<select id=\"page\" name=\"page\" onchange=\"javascript:window.location='{$path}html/$list/{$film}_'+this.options[this.selectedIndex].value +'.html'\">\n";
$out .= " <option value=\"1\">請(qǐng)選擇</option>\n";
for ($i = 1;$i <= $this->pagecount;$i++){
$out .= " <option value=\"$i\">第{$i}頁(yè)</option>\n";
}
$out .= "</select>\n";
return $out;
}
/**
* 樣式2(discuz)
*/
function multi($mpurl,$page = 10) {
$multipage = '';
$mpurl .= strpos($mpurl, '?') !== false ? '&' : '?';
$realpages = 1;
if($this->infocount > $this->items) {
$offset = 2;
$realpages = @ceil($this->infocount / $this->items);
$pages = $this->maxpages && $this->maxpages < $realpages ? $this->maxpages : $realpages;
if($page > $pages) {
$from = 1;
$to = $pages;
} else {
$from = $this->pageno - $offset;
$to = $from + $page - 1;
if($from < 1) {
$to = $this->pageno + 1 - $from;
$from = 1;
if($to - $from < $page) {
$to = $page;
}
} elseif($to > $pages) {
$from = $pages - $page + 1;
$to = $pages;
}
}
$multipage = ($this->pageno - $offset > 1 && $pages > $page ? '<a href="'.$mpurl.'page=1" class="first">1 ...</a>' : '').
($this->pageno > 1 ? '<a href="'.$mpurl.'page='.($this->pageno - 1).'" class="p_redirect"><<</a>' : '');
for($i = $from; $i <= $to; $i++) {
$multipage .= $i == $this->pageno ? '<a class="p_curpage"><strong>'.$i.'</strong></a>' :'<a href="'.$mpurl.'page='.$i.'" class="p_num">'.$i.'</a>';
}
$multipage .= ($this->pageno < $pages ? '<a href="'.$mpurl.'page='.($this->pageno + 1).'" class="p_redirect">>></a>' : '').
($to < $pages ? '<a href="'.$mpurl.'page='.$pages.'" class="last">... '.$realpages.'</a>' : '').
($pages > $page ? '<kbd><input type="text" name="custompage" size="3" onkeydown="if(event.keyCode==13) {window.location=\''.$mpurl.'page=\'+this.value; return false;}" /></kbd>' : '');
$multipage = $multipage ? '<div class="p_bar"><a class="p_total"> '.$this->infocount.' </a><a class="p_pages"> '.$this->pageno.'/'.$pages.' </a>'.$multipage.'</div>' : '';
}
return $multipage;
}
/**
* 樣式3(zol)
*/
public function zol($mpurl)
{
$mpurl .= strpos($mpurl, '?') !== false ? '&' : '?';
$code = '<div class="f22 mt10 hei14">';
$code .= '<div style="line-height:30px">第<font class="a_hong14b">'.$this->pageno.'</font><font class="a_hei14">/'.$this->pagecount.'</font>頁(yè) 每頁(yè)<font class="a_hei14">'.$this->items.'</font> 共<font class="a_hong14b">'.$this->infocount.'</font>款產(chǎn)品</div>';
$code .= '<table border="0" align="right" cellpadding="0" cellspacing="3">';
$code .= '<tr>';
if ($this->pageno == $this->prev)
{
$code .= "<td width='64' align='center' class='bd_hui huei14b'><a disabled='disabled' class='a_hui12b'><<上一頁(yè)</a></td>";
}
else
{
$code .= "<td width='64' align='center' class='bd_lan a_lan14'><a href='{$mpurl}page={$this->prev}' class='a_lan12b'><<上一頁(yè)</a></td>";
}
$i = 10 ;
$k = 1;
if ($this->pageno < 1)
{
$this->pageno = 1;
}
if ($this->pageno > $this->pagecount)
{
$this->pageno = $this->pagecount;
}
$s = $this->pageno-2;
if ($s <= 0)
{
$s = 1;
}
$e = $this->pageno+2;
if ($e < 5 )
{
$e = 5;
}
if ($e > $this->pagecount)
{
$e = $this->pagecount;
}
for ($j=$s;$j<=$e;$j++)
{
if ($this->pageno == $j)
{
$code .= '<td width="22" bgcolor="#2E6AB1" class="bei14" align="center">'.$j.'</td>';
}
else
{
$code .= "<td width='22' align='center' class='bd_lan a_lan14' onMouseOver=\"this.style.border='1px solid #2062A4'\" onMouseOut=\"this.style.border='1px solid #AACCEE'\" style=\"CURSOR: hand\" onClick=\"javascript:window.location=('{$mpurl}page={$j}')\">$j</td>";
}
}
if ($this->pageno == $this->pagecount)
{
$code .= "<td align='center' width='64' class='bd_hui huei14b'><a disabled='disabled' >下一頁(yè)>></a></td>";
}
else
{
$code .= "<td align='center' width='64' class='bd_lan lan14b'><a href='{$mpurl}page={$this->next}' class='a_lan12b'>下一頁(yè)>></a></td>";
}
$code .= '</tr>';
$code .= '</table>';
$code .= '</div>';
return $code;
}
}
您可能感興趣的文章:
- 精美漂亮的php分頁(yè)類(lèi)代碼
- ThinkPHP使用心得分享-分頁(yè)類(lèi)Page的用法
- PHP通用分頁(yè)類(lèi)page.php[仿google分頁(yè)]
- mysql+php分頁(yè)類(lèi)(已測(cè))
- 高效mongodb的php分頁(yè)類(lèi)(不使用skip)
- php封裝的page分頁(yè)類(lèi)完整實(shí)例
- PHP 分頁(yè)類(lèi)(模仿google)-面試題目解答
- 仿dedecms下拉分頁(yè)樣式修改的thinkphp分頁(yè)類(lèi)實(shí)例
- php相當(dāng)簡(jiǎn)單的分頁(yè)類(lèi)
- 仿Aspnetpager的一個(gè)PHP分頁(yè)類(lèi)代碼 附源碼下載
- PHP封裝的完整分頁(yè)類(lèi)示例
相關(guān)文章
php微信公眾平臺(tái)開(kāi)發(fā)類(lèi)實(shí)例
這篇文章主要介紹了php微信公眾平臺(tái)開(kāi)發(fā)類(lèi),實(shí)例分析了針對(duì)微信消息的響應(yīng)、回復(fù)、編碼等相關(guān)技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2015-04-04微信公眾號(hào)點(diǎn)擊菜單即可打開(kāi)并登錄微站的實(shí)現(xiàn)方法
這篇文章主要介紹了微信公眾號(hào)點(diǎn)擊菜單即可打開(kāi)并登錄微站的實(shí)現(xiàn)方法,以實(shí)例形式對(duì)回調(diào)、菜單及參數(shù)的處理等具體實(shí)現(xiàn)步驟與功能代碼都做了較為詳細(xì)的描述,對(duì)于微信公眾號(hào)的開(kāi)發(fā)來(lái)說(shuō)具有很好的參考借鑒價(jià)值,需要的朋友可以參考下2014-11-11php setcookie函數(shù)的參數(shù)說(shuō)明及其用法
這篇文章主要介紹了php setcookie函數(shù)的參數(shù)說(shuō)明及其用法,需要的朋友可以參考下2014-04-04JavaScript+PHP實(shí)現(xiàn)視頻文件分片上傳的示例代碼
這篇文章主要介紹了基于JavaScript+PHP實(shí)現(xiàn)視頻文件分片上傳,視頻文件分片上傳,整體思路是利用JavaScript將文件切片,然后循環(huán)調(diào)用上傳接口 upload.php 將切片上傳到服務(wù)器,文中有詳細(xì)代碼供大家參考,需要的朋友可以參考下2024-02-02php用戶注冊(cè)時(shí)常用的檢驗(yàn)函數(shù)實(shí)例總結(jié)
這篇文章主要介紹了php用戶注冊(cè)時(shí)常用的檢驗(yàn)函數(shù),以類(lèi)的形式實(shí)例總結(jié)了用戶名驗(yàn)證、郵箱驗(yàn)證、QQ驗(yàn)證等常用的驗(yàn)證技巧,非常具有實(shí)用價(jià)值,需要的朋友可以參考下2014-12-12php正則取img標(biāo)記中任意屬性(正則替換去掉或改變圖片img標(biāo)記中的任意屬性)
因有一項(xiàng)目新聞發(fā)布系統(tǒng),數(shù)據(jù)庫(kù)內(nèi)容字段中存儲(chǔ)的是原圖的路徑(當(dāng)然還有其他文字內(nèi)容啦,內(nèi)容里插圖時(shí),存的是圖片路徑),但前臺(tái)想使用縮略圖,琢磨1小時(shí)余,得到以下結(jié)果,可解決問(wèn)題2013-08-08PHP統(tǒng)計(jì)目錄中文件以及目錄中目錄大小的方法
這篇文章主要介紹了PHP統(tǒng)計(jì)目錄中文件以及目錄中目錄大小的方法,涉及PHP針對(duì)文件及目錄的遍歷,讀取及運(yùn)算的相關(guān)技巧,需要的朋友可以參考下2016-01-01