//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 of the total data amount divided 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 each page, 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
}
}
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))...{
?>