$limit=25;
if (!empty($start)) $start=0;
if (!empty($s)) $s=0;
mysql_connect("localhost","","");
mysql_select_db(database);
//统计数据库记录总数
$result=mysql_query("select * from table");
$num=mysql_numrows($result);
$result=mysql_query("select * from table order by id limit $start,$limit");
$numb=mysql_numrows($result);
echo "
";
if (!empty($numb)) {
for($i=0;$i
$val=mysql_result($result,$i,"val");
$val1=mysql_result($result,$i,"val1");
echo "
$val |
$val1 |
";
}
}
echo "
";
//数字循环翻页的控制
echo "
";
echo "
页: | ";
//前翻控制
if ($s>20) {
if ($s==21) {
$st=$s-21;
} else {
$st=$s-20;
}
$pstart=$st*$limit;
echo "
echo "start=$pstart&s=$st>prve | ";
}
echo " >> | ";
//设置当前页对应页数无链接功能
$star=$start;
//注意循环的初始附值,仔细想想为什么不是 0
for ($page=$s;$page
$start=$page*$limit;
echo "
";
if($page!=$star/$limit) {
echo "
echo "start=$start&s=$s>";
}
echo $page;
if($page!=$star/$limit) {
echo "";
}
echo "
| ";
//控制数字页面限制显示功能,控制只显示 20 页
if ($page>0 && ($page%20)==0) {
if ($s==0) {
$s=$s+21;
} else {
$s=$s+20;
}
$start=$start+$limit;
if ((($num/$limit)-1)>$page) {
echo "
|
echo "start=$start&s=$s>next | ";
}
//注意跳出循环的控制
break;
}
}
echo "
";
?>
以上的程已序可以完成强大的循环翻页功能