Php getting started knowledge point 2 simple paging process and principle of PHP _ PHP Tutorial

Source: Internet
Author: User
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...

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.