首頁 >後端開發 >php教程 > php中分页代码解决方案

php中分页代码解决方案

WBOY
WBOY原創
2016-06-13 13:34:52880瀏覽

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