php 分页函数

程序调用:$page =
multi(记录总数,每页显示数,当前页数,URL字符串,前后最大显示页数);模版调用:div{$page}/div//分页函数显示functionmulti($count,$tpp,$page,$url,$maxto=5){$string=$string_f=$string_e=$string_ee=”;$page=abs($page);$maxpage=Ceil($count/$tpp)==0?1:Ceil($count/$tpp);$url=strrpos($url,’?’)?$url.”:$url.’?’;if($count==0){$string_ff=spanclass=p5title=没有记录没有记录/span;}else{$string_ff=”;}$string_ff.=spanclass=p1title=共.$maxpage.页/当前第.$page.页共.$maxpage.页/第.$page.页/span;if($page==1OR$maxpage==0OR$page$maxpage){$string_f=spanclass=p2首页/spanspanclass=p2/span;}else{$string_f=aclass=p4href=.$url.page=1首页/aaclass=p4href=.$url.page=.($page-1)./a;}if($page==$maxpageOR$maxpage==0OR$page$maxpage){$string_e=spanclass=p2/spanspanclass=p2尾页/span;}else{$string_e=aclass=p4href=.$url.page=.($page+1)./aaclass=p4href=.$url.page=.$maxpage.尾页/a;}$for_end=($maxpage($page+$maxto))?($page+$maxto):$maxpage;$for_begin=(($page-$maxto)1)?($page-$maxto):1;for($i=$for_澳门新葡亰手机版,begin;$i=$for_end;$i++){if($i==$page){$string.=spanclass=p3$i/span;}else{$string.=aclass=p4href=.$url.page=.$i.$i/a;}}if($page$maxpageOR$page==0){$string_ee=spanclass=p5没有找到当前页!/spanaclass=p5href=.$url.page=1首页/aaclass=p5href=.$url.page=.$maxpage.尾页/a;return$string_ee;}else{return$string_ff.$string_f.$string.$string_e.$string_ee;}}