page.class.php :
<?phpview codenamespace tools;
class
page
private
function
setlimit()";}
private
function geturi($pa
)
return
$url
; }
public
function __get($args
)
else
}private
function
start()
else
}private
function
end()
private
function
first()
else
&page=1'> ";
}return
$html
; }
private
function
prev
()
else
&page=" . ($this->page - 1) . "'> ";
}return
$html
; }
private
function
pagelist()
$linkpage .= " $this->uri}&page='> ";
}$linkpage .= " ";
for ($i = 1; $i
<= $inum; $i++) &page='> ";
} else
}return
$linkpage
; }
private
function
next
()
else
&page=" . ($this->page + 1) . "'> ";
}return
$html
; }
private
function
last()
else
&page=" . ($this->pagenum) . "'> ";
}return
$html
; }
private
function
gopage()
" value="' . $this->page . '" style="width:25px">' . $this->pagenum . ')?' . $this->pagenum . ':this.previoussibling.value;location=\'' . $this->uri . '&page=\'+page+\'\'"> ';
}public
function fpage($display = array(0, 1, 2, 3, 4, 5, 6, 7, 8))
";
$html[1] = " 每頁顯示" . ($this->end() - $this->start() + 1) . "條,本頁-條 ";
$html[2] = "/頁 ";
$html[3] = $this->first();
$html[4] = $this->prev
();
$html[5] = $this->pagelist();
$html[6] = $this->next
();
$html[7] = $this->last();
$html[8] = $this->gopage();
$fpage = '';
foreach ($display
as$index
)
return
$fpage
; }
}
使用例子:
$goods = d("goods");// 1)分頁設定
$total = $goods->count(); // 總記錄數
$listrows = 7; // 每頁顯示條數
// 2)例項化分頁物件
$page = new \tools\page($total, $listrows);
// 3)分頁 sql 語句
$sql = "select * from sw_goods order by goods_id desc " . $page->limit;//limit 方法返回'limit xx,xx'
$info = $goods->query($sql);
// 4)製作頁碼列表
$fpage = $page->fpage(array(3,4,5,6,7,8)); // 前面的統計資訊不要
// 5)分配陣列
$this->assign("info", $info);
$this->assign("pagelist", $fpage);
$this->display("showgoodslist");
自定義分頁類
1.首先定義乙個分頁類 class page private function getpage private function first 顯示當前頁 list.this cpage.顯示當前頁之後的頁數 uri.page this pages.末頁 else private function s...
GridView自定義分頁類
今天查詢相關資料時,看到這個類寫的很好,就轉過來了啊,感謝原創者!下面直接是類的 一看就明白!public class pageing private int intpagecountww 0 總頁數 總頁數 public int getpagecount private string strpag...
php 資料分頁類,可自定義多個分頁樣式
呼叫方法 測試分頁 public function pagetestaction 分頁類的源 分頁類 呼叫方式 p new page 總頁數,顯示頁數,當前頁碼,每頁顯示條數,鏈結 print r p getpages 生成乙個頁碼陣列 鍵為頁碼,值為鏈結 echo p showpages 1 生成...