PHPダイナミック改ページ関数、PHP開発改ページは必須です。


貼り付けコード:
 
/**
*
*
* @param int $count
* @param int $perlogs
* @param int $page
* @param string $url
*/
function pagination($count,$perlogs,$page,$url,$anchor=''){
$pnums = @ceil($count / $perlogs);
$re = '';
$urlHome = preg_replace("|[\?&/][^\./\?&=]*page[=/\-]|","",$url);
for ($i = $page-5;$i <= $page+5 && $i <= $pnums; $i++){
if ($i > 0){
if ($i == $page){
$re .= " <span>$i</span> ";
} elseif($i == 1) {
$re .= " <a href=\"$urlHome$anchor\">$i</a> ";
} else {
$re .= " <a href=\"$url$i$anchor\">$i</a> ";
}
}
}
if ($page > 6) $re = "<a href=\"{$urlHome}$anchor\" title=\" \">&laquo;</a><em>...</em>$re";
if ($page + 5 < $pnums) $re .= "<em>...</em> <a href=\"$url$pnums$anchor\" title=\" \">&raquo;</a>";
if ($pnums <= 1) $re = '';
return $re;
}