 <?php
/////////////////////////////////////////////////////////
/////              分页函数（page.inc.php）         /////
/////$nums         传入列表总数                     /////
/////$limit        传入每页限制数                   /////
/////$url          传入上下页地址                   /////
/////$pagetype     判断页数标记符                   /////
/////////////////////////////////////////////////////////
function page($nums,$limit,$url,$pagetype,$list){

 
//计算总页数 $numpage
$numPage = $nums/$limit;
   if($nums<$limit){
   $numPage = 1;
   }else{
   for($i=0;$i<$numPage;$i++){
		$y = $i+1;
		if($y>$numPage){
		$numPage = $y;
			}
		}
	}
   //计算当前页  $page
	if($pagetype == NULL){
	$pagetype  =  'page';
	$getpage   =  $_GET['page'];
	}else{
	$pagetype  =  $pagetype;
	$getpage   =  $_GET["$pagetype"];
	}
if($getpage==NULL){
		$page      =  1;
	}elseif($getpage<=0){
		$page      =  1;
	}elseif($getpage>$numPage){
		$page      =  1;
	}else{
		$page      =  $getpage;
	}
//区分翻页
if($page!=1){
			$u      =    $page-1;
			$up     =    '<a href='.$url.$pagetype.'='.$u.'>上一页</a>';
		}else{
			$up     =    '上一页';
		}
 if($page!=$numPage){
			$d      =    $page+1;
			$down   =     '<a href='.$url.$pagetype.'='.$d.'>下一页</a>';
		}else{
			$down   =    '下一页';
	     }	  
if($list == 'NO' ){
		$pages = $up.'-'.$down;
	}elseif($list=='view'){
		$jumpMeun .= '<script type="text/javascript">function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location=\'"+selObj.options[selObj.selectedIndex].value+"\'");
  if (restore) selObj.selectedIndex=0;
}</script><form action="" method="get"><select name="jumpMenu" id="jumpMenu" onchange="MM_jumpMenu(\'parent\',this,1)">';
for($i=1;$i<=$numPage;$i++){
if($i == $_GET[$pagetype]){
		$mr = ' selected="selected"';
	}else{
		$mr = '';
	}
		$jumpMeun.='<option value="'.$url.$pagetype.'='.$i.'"'.$mr.' >第'.$i.'/'.$numPage.'页</option>';
	}
	$jumpMeun .=' </select></form>';
	$pages = '<table border="0" class="page"><tr><td class="left">'.$up.'</td><td class="center" valign="middle">'.$jumpMeun.'</td><td class="right">'.$down.'</td></tr></table>';
}else{
	$pages = '第'.$page.'/'.$numPage.'页|共'.$nums.'条记录<br>'.$up.'-'.$down;
}	

return $pages;
}
function pagen($nums,$limit){
$numPage = $nums/$limit;
		if($nums<$limit){
		$numPage = 1;
   }else{
	for($i=0;$i<$numPage;$i++){
		$y = $i+1;
		if($y>$numPage){
			$numPage = $y;
			}
		}
	}
  return $numPage;
}
/*
class page_info($nums,$limit,$url,$pagetype,$style){
//声明变量
var $nums;      //储存总记录数
var $limit;     //储存限制条数
var $url;       //储存地址
var $pagetype;  //储存分页标示
var $style;     //储存显示样式
//构造函数  
function __construct($nums,$limit,$url,$pagetype,$style){
$this->nums     =   $nums;
$this->limit    =   $limit;
$this->url      =   $url;
$this->pagetype =   $pagetype;
if($pagetype==NULL){
$this->pagetype='p';
}
$this->style   =   $style;
}
//计算总页数
function page_nums(){
   //计算总页数 $numpage
    $page_nums = $this->nums/$this->limit;
    if($this->nums < $this->limit){
        $page_nums = 1;
    }else{
    for($i=0;$i<$page_nums;$i++){
       $y = $i+1;
	   if($y>$page_nums){
	   $page_nums = $y;
	   }
     }
}
    return $page_nums;//返回总页数
  }
//计算当前页
function page_dq(){
   $page_dq = $_GET[$this->pagetype];
   if($page_dq<=0){
     $page_dq=1;
   }
   if($page_dq>$this->page_nums()){
   $page_dq = $this->page_nums();
   }
   return $page_dq;
   }

function page_pdn($type){
if($type=='pgup'){
  if($this->page_dq()!=1){
      $u      =    $this->page_dq()-1;
      $ud     =    '<a href='.$this->url.$this->pagetype.'='.$u.'&sid='.$_GET['sid'].'>上一页</a>';
	  }else{
	  $ud     =    '上一页';
	  }
	  }elseif($type=='pgdn'){
	  
 if($this->page_dq() != $this->page_nums()){
      $d      =    $this->page_dq()+1;
      $ud   =     '<a href='.$this->url.$this->pagetype.'='.$d.'&sid='.$_GET['sid'].'>下一页</a>';
	  }else{
	  $ud  =    '下一页';
	        }  
		}
		return $ud; 
       }
	  
} 

类结束*/
?>