Implement the data paging display function based on PHP, and implement pagination display by php _ PHP Tutorial

Source: Internet
Author: User
The data paging display function is implemented based on PHP, and php implements paging display. The data paging display function is implemented based on PHP. The php implementation page display example in this article shares the PHP implementation code of the data paging display function for your reference, the specific content is as follows: implement the data paging display function based on PHP, and implement paging display by php

The example in this article shares the PHP implementation code of the data paging display function for your reference. The details are as follows:

Implementation code:

  
   User list<? Php $ con = mysql_connect ("localhost", "root", ""); mysql_query ("set names utf8"); mysql_select_db ("zhiye", $ con ); $ pageSize = 1; // The number displayed per page $ rowCount = 0; // Get $ pageNow = 1 from the database; // page number displayed. // If pageNow exists, the first page is displayed by default. If (! Empty ($ _ GET ['pagenow']) {$ pageNow = $ _ GET ['pagenow'];} $ pageCount = 0; // indicates the total number of pages $ sql1 = "select count (id) from user"; $ res1 = mysql_query ($ sql1); if ($ row1 = mysql_fetch_row ($ res1 )) {$ rowCount = $ row1 [0];} // calculates the total number of pages. ceil takes 1 $ pageCount = ceil ($ rowCount/$ pageSize )); // when using SQL statements, note that values should be assigned to some variables. $ Pre = ($ pageNow-1) * $ pageSize; $ sql2 = "select * from user limit $ pre, $ pageSize"; $ res2 = mysql_query ($ sql2 ); while ($ row = mysql_fetch_assoc ($ res2) {echo $ row ['User _ name']."
"; Echo $ row ['name']."
"; Echo $ row ['email ']."
"; Echo $ row ['password']."
"; Echo $ row ['tel']."
";}For ($ I = 1; $ I <=$ pageCount; $ I ++) {echo" $ I ";}?>

The above is all the content of this article. I hope you can give us a reference and support the customer's home.

Examples in this article share the PHP implementation code of the data paging display function for your reference. the specific content is as follows...

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.