Home  >  Article  >  Backend Development  >  php中分页代码解决方案

php中分页代码解决方案

WBOY
WBOYOriginal
2016-06-13 10:18:06864browse

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; 

?>

娣诲
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn