$result_count=select("hy_news_en",$where,‘‘,‘‘,‘count(1)‘);
$count=mysql_fetch_array($result_count);
$count=$count[0];//总共有多少条
$page_size=5;//每页多少条
$page_count=ceil($count/$page_size);//总页数
$p=$_REQUEST[‘p‘]>$page_count?$page_count:$_REQUEST[‘p‘];//开始页面,如果超过总页数,则为总页数
$p=$p<1?1:$p;//如果小于0,则为第一页
$start_p=intval(($p-1)/$page_size);
//上page_size页
if($p> $page_size){
$page_prev=$start_p*$page_size-($page_size-1);
$page_prev=‘latest_pro.php?act=‘.$_REQUEST[‘act‘].‘&p=‘.$page_prev;
}
//下page_size页
if(($start_p*$page_size+$page_size)<$page_count){
$page_next=$start_p*$page_size+($page_size+1);
$page_next=‘latest_pro.php?act=‘.$_REQUEST[‘act‘].‘&p=‘.$page_next;
}
//中间page_size页
$end_count=($start_p*$page_size+$page_size)>$page_count?$page_count:($start_p*$page_size+$page_size);
for($i=$start_p*$page_size+1;$i<=$end_count;$i++){
$page[$i]=‘latest_pro.php?act=‘.$_REQUEST[‘act‘].‘&p=‘.$i;
}
$p=$page_size*($p-1);//数据库中从0起始
$limits="{$p},{$page_size} ";
//分页处理end