php分页代码
函数
function multi($count, $perpage, $currentpage, $url) {
//multi pages
if ($count > $perpage) {
$num = ceil($count / $perpage);
$string = "<a href="" . BASE_URL . $url . "&page=1""
. ($currentpage == 1 ? " style="font-weight: bold"" : "") . ">1</a>";
for ($i = 2; $i <= $num; $i++) {
$string .= " | <a href="" . BASE_URL . $url . "&page=" . $i . """
. ($i == $currentpage ? " style="font-weight: bold"" : "") . ">" . $i . "</a>";
}
return $string;
} else {
return "";
}
}
调用:
<PRE class=brush:php>//multi page
$page = empty($_GET['page']) ? 1 : intval($_GET['page']);
$perpage = 3;
$start = ($page - 1) * $perpage;
$multi = multi($count, $perpage, $page, $pageurl);
</PRE>