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;
}
?>
娣诲