Home  >  Article  >  Backend Development  >  php分页,该如何处理

php分页,该如何处理

WBOY
WBOYOriginal
2016-06-13 13:45:54824browse

php分页


$pageCount = 9;//总页数
$pageNow = 3;//用户输入的页数
$i = 3;//显示的页数
$j = $pageCount/$i; //可以滚动的次数
$arr=array() ;

//控制滚动的次数
for($k=0;$k
//控制翻页
if($pageNow==3*$k) {

for($e=($k*3)+1;$e
$arr[] = $e;
//echo $e;
}
//echo "";
}else {
//输出当前显示页数
for($a=0;$a $arr[$a];

}

}
}

?>
帮忙给看下,那里出问题了。





------解决方案--------------------

PHP code
$pageCount = 9;//总页数
$pageNum = 3;//显示的页码数
$pageNow = $_GET['page'] ? $_GET['page'] : 1;//用户输入的页数
if( $pageNow == $pageCount ) $pageNow = 1; //循环滚动,加上这句

$pageStart = floor($pageNow / $pageNum) * $pageNum + 1; //显示的起始页码
$pageEnd = $pageStart + $pageNum;//显示的终止页码+1

for($i=$pageStart; $i$i] ";
} <div class="clear">
                 
              
              
        
            </div>
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