首页 >php教程 >php手册 >求一个可移植性强一点的分页程序!!!!!!!!!!!!

求一个可移植性强一点的分页程序!!!!!!!!!!!!

WBOY
WBOY原创
2016-06-21 09:08:141066浏览

程序|分页

function multi($num, $perpage, $curr_page, $mpurl) {
$multipage = '';
if($num > $perpage) {
$page = 10;
$offset = 2;

$pages = ceil($num / $perpage);
$from = $curr_page - $offset;
$to = $curr_page + $page - $offset - 1;
if($page > $pages) {
$from = 1;
$to = $pages;
} else {
if($from $to = $curr_page + 1 - $from;
$from = 1;
if(($to - $from) $to = $page;
}
} elseif($to > $pages) {
$from = $curr_page - $pages + $to;
$to = $pages;
if(($to - $from) $from = $pages - $page + 1;
}
}
}
$multipage .= " ";
for($i = $from; $i if($i != $curr_page) {
$multipage .= "
[$i] ";
} else {
$multipage .= '['.$i.'] ';
}
}
$multipage .= $pages > $page ? " ... [$pages] >>" : " >>";
}
return $multipage;
}



声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn