首页 > php教程 > php手册 > 通用分页函数 split_page()

通用分页函数 split_page()

WBOY
发布: 2016-06-21 09:07:06
原创
1231 人浏览过

分页|函数

// 分页显示:[1]... [] - [>>] ...[232]
// url Format: ./list.php?page= ; system will add the Pagenum after the Url automaticly
// $Id: split_page.php,v 1.1.1.1 2002/08/24 14:26:41 hightman Exp $
 
function split_page($url, $total, $curpage = 1, $perpage = 15, $perlist = 8) {
    if ($total    
    if ($curpage     $totalpage = ceil($total / $perpage);
    $totallist = ceil($totalpage / $perlist);
   
    if ($curpage > $totalpage) $curpage = $totalpage;
    $curlist = ceil($curpage / $perlist);
   
    $toppage = $curlist * $perlist;
    if ($toppage > $totalpage) $toppage = $totalpage;
   
    $botpage = ($curlist - 1) * $perlist + 1;
    if ($botpage    
    $ret = '';
   
    if ($curlist > 1) {
         $ret .= "[1]...\n";
         $ret .= "[ -\n";
    }
   
    if ($curpage > 1)
         $ret .= "
[\n";
   
    do {
         if ($botpage == $curpage)
             $ret .= "[" . $botpage . "]\n";
        else
             $ret .= "
[" . $botpage . "]\n";
    } while ($botpage++    
    if ($totalpage > $curpage)
            $ret .= "[>]\n";
   
    if ($totallist > $curlist) {
            $ret .= "- [>>]\n";
            $ret .= "...[" . $totalpage . "]\n";
    }
   
    $ret .= "Total: " . $total;
    return ($ret);
}



相关标签:
来源:php.cn
本站声明
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
热门推荐
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板