The paging function of PHP .? Php creates a database connection $ linkmysql_connect (localhost, root, wyh7ye); obtain the current page number mysql_select_db (test, $ link ); if (isset ($ _ GET [page])... {$ pageintval ($ _ GET [page]);} e // Establish a database connection
$ Link = mysql_connect ("localhost", "root", "wyh7ye ");
; // Obtain the current page number
Mysql_select_db ("test", $ link );
If (isset ($ _ GET ['Page'])... {
$ Page = intval ($ _ GET ['Page']);
}
Else ...{
$ Page = 1;
}
// Number of pages per page
$ Page_size = 4;
// Obtain the total data volume
$ SQL = "select * from user ";
$ Result = mysql_query ($ SQL, $ link );
While ($ row = mysql_fetch_array ($ result ))...{
$ I = $ I + 1;
}
$ Amount = $ I;
// Count the total number of pages
If ($ amount )...{
If ($ amount <$ page_size)... {$ page_count = 1 ;}// if the total data volume is less than $ PageSize, there is only one page
If ($ amount % $ page_size)... {// Retrieve the total data volume divided by the remainder of each page
$ Page_count = (int) ($ amount/$ page_size) + 1; // if there is a remainder, the number of pages equals the total data volume divided by the result of each page number and then adds one
} Else ...{
$ Page_count = $ amount/$ page_size; // if there is no remainder, the number of pages equals the total data volume divided by the result of each page
}
}
Else ...{
$ Page_count = 0;
}
// Obtain data and return results 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 ))...{
?>
}
}
// Flip 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 | last page ";
}
Echo $ page_string;
?>
Http://www.bkjia.com/PHPjc/318270.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/318270.htmlTechArticle? Php // create a database connection $ link = mysql_connect (localhost, root, wyh7ye); // Obtain the current page number mysql_select_db (test, $ link ); if (isset ($ _ GET [page])... {$ page = intval ($ _ GET [page]);} e...