php 带条件查询 分页代码 - php分页
来源:自学PHP网
时间:2014-11-30 14:41 作者:
阅读:次
[导读] if(!isset($_get[absolutepage])){$absolutepage=1;//当前页//开源代码phpfensi.com}if($_get[absolutepage]==0){$absolutepage=1;}else{$absolutepage=$_get[absolutepage];$absolutepage=intval(......
php 带条件查询 分页代码
- if(!isset($_get[absolutepage])){
- $absolutepage=1;
- }
- if ($_get[absolutepage]==0){
- $absolutepage=1;
- }else {
- $absolutepage=$_get[absolutepage];
- $absolutepage=intval($absolutepage);
- }
- $pagesize=5;
- $a= (($absolutepage - 1) * $pagesize);
- $sql1=$sql." limit $a,$pagesize ";
-
- $nums=mysql_num_rows($query);
- $pagecount = (int)(($nums - 1) / $pagesize) + 1;
- if ($absolutepage>1 && $nums>1){
- $prevpage=$absolutepage-1;
- }
- if ($absolutepage>=1 && $absolutepage<$pagecount){
- $nextpage=$absolutepage+1;
- }
- if ($absolutepage > $pagecount) {
- $absolutepage = $pagecount;
- }
- $prevpage="<a href='".(strpos($_server['request_uri'],'?') ? "{$_server['request_uri']}&" : '?')."absolutepage=$prevpage'>上一页</a>";
- $nextpage="<a href='".(strpos($_server['request_uri'],'?') ? "{$_server['request_uri']}&" : '?')."absolutepage=$nextpage'>下一页</a>";
|