//此範例摘自phpbuilder.com n"; TechArticle
//稍加翻譯
//
$limit=20; // 每頁顯示的行數
$numresults=mysql_query("select * from TABLE where YOUR CONDITIONAL HERE order by WHATEVER");//換成你所需要的sql語句 >
// next determine if offset has been passed to script, if not use 0
if (empty($offset)) {
$offset=1;> // 得到查詢結果
$result=mysql_query("select id,name,phone ".
"from TABLE where YOUR CONDITIONAL HERE ".
"order by WHATEVER limit" $
// 現在顯示查詢結果
while ($data=mysql_fetch_array($result)) {
// 在這裡插入您要顯示的結果以及樣式
🎜>// 顯示器按鈕
if ($offset!=1) { // bypass PREV link if offset is 1
$prevoffset=$offset-20; "$PHP_SELF?offset=$prevoffset">上一頁 n";
}
// 計算頁數
$pages=intval($numrows/$limit);
// $pages now contains int of pages needed unless there is a remainder from division
if ($numrows%$limit) {
// has remainder so pages ;
}
for ($i=1;$i$newoffset=$limit*($i-1) ;
print "$i n";
}
// check to see if last page if (!(($offset/$limit)==$pages) && $pages!=1) {
// not last page so give NEXT link
$newoffset=$offset $limit;
print "下一頁
}
?>
http://www.bkjia.com/PHPjc/315557.html
www.bkjia.com
true
http: //www.bkjia.com/PHPjc/315557.html