Simple example of data display by page using PHP, and example of php display by PAGE
Paging is a frequently used function in background management, which facilitates the management of a large amount of data.
The instance code is as follows:
<! DOCTYPE html>
When there is a large amount of data, the above method cannot be used.
<? 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 ); // $ SQL = "select * from user"; // $ res = mysql_query ($ SQL, $ con); while ($ row = mysql_fetch_assoc ($ res2 )) {echo $ row ['user _ name']. "<br>"; echo $ row ['name']. "<br>"; echo $ row ['email ']. "<br>"; echo $ row ['Password']. "<br>"; echo $ row ['tel ']. "<br>";} if ($ pageNow> 1) {$ prePage = $ pageNow-1; echo "< Href = 'userlist. php? PageNow = $ prePage '> pre </a> ";} if ($ pageNow <$ pageCount) {$ nextPage = $ pageNow + 1; echo" <a href = 'userlist. php? PageNow = $ nextPage '> next </a> "; echo" Current page {$ pageNow}/total page {$ pageCount ";} echo "<br/>" ;?> <Form action = "userList. php"> <input type = "text" name = "pageNow"> <input type = "submit" value = "GO"> </form>
The simple example of the above PHP implementation of data paging display is all the content shared by xiaobian. I hope to give you a reference and support for the help house.