Home  >  Article  >  php教程  >  求一个可移植性强一点的分页程序!!!!!!!!!!!!

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

WBOY
WBOYOriginal
2016-06-21 09:08:141026browse

程序|分页

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;
}



Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn