Php beginners learning knowledge point 2 PHP simple paging process and principle .? Phprequire... incconn. php ;?? Php initial parameter settings $ pagesize5; page size $ pagenum1; default: the first page step: GET the current page if ($ _ GET) {if ($ _ GET Require '../inc/conn. php ';
?>
// Initial parameter settings
$ Pagesize = 5; // page size
$ Pagenum = 1; // The first page is displayed by default.
// Step 1: obtain the current page
If ($ _ GET ){
If ($ _ GET ['pagenum']) {
$ Pagenum = $ _ GET ['pagenum'];
}
}
// Step 2: obtain the content list of the current page
$ SQL = "Select * From message limit". ($ pagenum-1) * $ pagesize. ", $ pagesize ";
$ Result = mysql_query ($ SQL );
While ($ row = mysql_fetch_array ($ result) = true ){
Echo ''. $ row [" title "].'';
}
// Step 3: obtain the number of records
$ SQL = "Select id From message ";
$ Result = mysql_query ($ SQL );
$ Rownum = mysql_num_rows ($ result );
// Step 4: count the number of minutes
If ($ rownum % $ pagesize) = 0 ){
$ Pagecount = $ rownum/$ pagesize;
} Else {
$ Pagecount = (int) ($ rownum/$ pagesize );
}
// Step 5: Get the paging link
$ Url = $ _ SERVER ["REQUEST_URI"];
$ Url = parse_url ($ url );
$ Url = $ url ["path"];
// Step 6: output the paging link
If ($ pagenum = 1 ){
Echo "[First Page] [previous page]";
} Else {
Echo "[First Page] [previous page]";
}
If ($ pagecount = $ pagenum ){
Echo "[Next Page] [last page]";
} Else {
Echo "[Next Page] [last page]";
}
?>
Http://www.bkjia.com/PHPjc/323833.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/323833.htmlTechArticle? Php require '../inc/conn. php ';? ? Php // set the initial parameter $ pagesize = 5; // page size $ pagenum = 1; // The default value is the first page. // Step 1: obtain the current page if ($ _ GET) {if ($ _ GET...