澳门新葡萄京官网首页实现“上一页”和“下一页amp;quot;按钮

?php //本例子摘自phpbuilder.com //稍加翻译 //sprming@netease.com
$limit=20; // 每页展现的行数 $numresults=mysql_query(“select * from
TABLE where YOU酷威 CONDITIONAL HERE order by
WHATEVE奥迪Q3″State of Qatar;//换来你所急需的sql语句
$numrows=mysql_澳门新葡萄京官网首页,num_rows($numresultsState of Qatar; // next determine if offset has
been passed to script, if not use 0 if (empty($offsetState of Qatar卡塔尔国 { $offset=1; }
// 取得查询结果 $result=mysql_query(“select id,name,phone “. “from
TABLE where YOU奥迪Q3 CONDITIONAL HERE “. “order by WHATEVEENVISION limit
$offset,$limit”State of Qatar; // 今后来得查询结果 while
($data=mysql_fetch_array($result卡塔尔国State of Qatar { //
在这里间插入您要出示的结果以至体制 } // 显示按键 if ($offset!=1卡塔尔国 { //
bypass PREV link if offset is 1 $prevoffset=$offset-20; print “a
href=”$PHP_SELF?offset=$prevoffset”/a nbsp; “; } // 总结页面数
$pages=intval($numrows/$limit卡塔尔国; // $pages now contains int of pages
needed unless there is a remainder from division if ($numrows%$limit卡塔尔国 {
// has remainder so add one page $pages++; } for ($i=1;$i=$pages;$i++State of Qatar {
// 呈现页数 $newoffset=$limit*($i-1); print “a
href=”$PHP_SELF?offset=$newoffset”$i/a nbsp; “; } // check to see if
last page if (!(($offset/$limit)==$pages) $pages!=1) { // not last page
so give NEXT link $newoffset=$offset+$limit; print “a
href=”$PHP_SELF?offset=$newoffset”/ap”; } ?

发表评论

电子邮件地址不会被公开。 必填项已用*标注