首页  >  文章  >  后端开发  >  php中分页代码解决方案

php中分页代码解决方案

WBOY
WBOY原创
2016-06-13 10:18:06892浏览

php中分页代码



Information


include "sql_class.php" ;
$mysql=new Db_Mysql() ;
$mysql->dbConnect() ;
//$error=new Script() ;

$pageSize=2 ;
 $page_string = ""; 
 $totalpage="" ;
if( isset($_GET['page']) ){ 
  $page = intval( $_GET['page'] ); 

else{ 
  $page = 1; 
}
$sql="select count(*) as amount from $mysql->table order by id desc" ;
$result = mysql_query($sql); 
$amount = mysql_result($result , 0 , "amount"); 
if($amount){ 
  if($amount $totalpage = 1;

  if( $amount % $pageSize ){
  $totalpage = intval($amount / $pageSize) + 1; 
  }else{ 
  $totalpage = $amount / $pageSize;
  } 

else{ 
  $totalpage = 1; 

?>

娣诲
声明:
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn