函数:

 

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 "";
	}
}
调用:
//multi page
$page = empty($_GET['page']) ? 1 : intval($_GET['page']);
$perpage = 3;
$start = ($page - 1) * $perpage;

$multi = multi($count, $perpage, $page, $pageurl);

posted on 2010-06-22 13:30  eagley  阅读(542)  评论(0编辑  收藏  举报