Home >Backend Development >PHP Tutorial >What are the new features of iphone5? PHP paging function

What are the new features of iphone5? PHP paging function

WBOY
WBOYOriginal
2016-07-29 08:36:531595browse

//Establish database connection
$link = mysql_connect("localhost", "root", "wyh7ye") ;
; // Get the current page number
mysql_select_db("test",$link);
if(isset($_GET[page]))...{
$page = intval($_GET[page]);
}
else...{
$page = 1;
}
//Quantity per page
$page_size =4;
//Get the total data amount
$sql = "select * from user";
$result = mysql_query($sql,$link);
while($row = mysql_fetch_array($result))...{
$i=$i+1;
}
$amount = $i;
// Calculate how many pages there are in total
if( $amount )...{
if( $amount < $page_size )...{ $page_count = 1; } //If the total data amount is less than $PageSize, then there is only one page
if( $amount % $page_size )...{ //Get the remainder after dividing the total data amount by the number of pages
       $page_count = (int)($amount / $page_size) + 1; //If there is a remainder, the number of pages is equal to the total data amount divided by the number of pages, rounded up and plus one
}else...{
       $page_count = $amount / $page_size; //If there is no remainder, the number of pages is equal to the total data amount divided by the number of pages per page
}
}
else...{
$page_count = 0;
}
// Get data and return the result in two-dimensional array format
if( $amount )...{
$sql = "select * from user order by id desc limit ". ($page-1)*$page_size .",$page_size";
$result =mysql_query($sql,$link);
while ($row =mysql_fetch_array($result))...{
?>



   
   
   
   


}
}
// Page turning link
$page_string="";
if( $page == 1 )...{
$page_string.="First page|Previous page|";
}
else...{
$page_string.= "First page|href=?page=".($page-1).">Previous page|";
}
if( ($page == $page_count) || ($page_count == 0) )...{
$page_string.="Next page|Last page";
}
else...{
$page_string.= "Next page|";
}
echo $page_string;
?>

The above introduces what are the new features of iphone5 and the paging function of PHP, including what are the new features of iphone5. I hope it will be helpful to friends who are interested in PHP tutorials.