/* $per_page每页记录数
* $total记录总数
* $url 基准URL
* $crr 当前页
* $link_count 链接数量
* $anchor 锚标记
*/
function pages_output($total,$per_page,$url,$crr=1,$anchor=array(),$link_count=4){
$count=ceil($total/$per_page); //求总页数
$next = $crr+1<=$count? $crr+1:$count;
$pre = $crr-1>0? $crr-1:1;
$url = trim($url);
if(!empty($anchor)){
foreach($anchor as $k=>$v){
$tips .='&'.$k.'='.$v;
}
}
$content = '
$content .= '.anppager {color: #646464;font-weight: bold;margin: 15px 0 0;padding: 0 0 10px 15px; text-align:center;}';
$content .= '.anppager a { display:inline-block; background: none repeat scroll 0 0 #FFFFFF;border: 1px solid #8D8D8D;color:#646464;
margin-right: 3px;padding: 2px 6px 1px;text-decoration: none;vertical-align:top;}';
$content .= '.anppager a.activate, .anppager a:hover {background: none repeat scroll 0 0 #FFBA00;border: 1px solid #646464; color: #2B2B2B;
}';
$content .= '.anppager span {display:inline-block; background: none repeat scroll 0 0 #FFFFFF;border: 1px solid #F1F1F1;color: #B6B6B6;
margin-right: 3px;padding: 2px 6px 1px;vertical-align:top;}';
$content .= '';
$pre_url = $url."?page=".$pre.$tips;
$next_url = $url."?page=".$next.$tips;
$last_url = $url."?page=".$count.$tips;
$begin = max(1, ($crr - intval($link_count/2)));
$ends = min(($begin + $link_count - 1), $count); // $ends, 显示时的终止页码.
$begin = max(1, ($ends - $link_count + 1)); // $begin, 显示时的起始页码.
$content.='
$content.='首页';
$content.='上一页';
for($i=0;$begin+$i<=$ends;$i++){
$page = $begin+$i;
$content.= $crr==($begin+$i)? '下一页';
$content .='尾页';
$content .='转到';
$content .='';
for($i=1;$i<=$count;$i++){
$content .=$i==$crr? ''.$i.'':''.$i.'';
}
$content .='
页
return $content;
}