1. query all records of the database, and Display $ linkmysql_connect (localhost, root, 123); mysql_select_db (yanhua); mysql_query (setnamesutf8) on a page ); first, you need to know the number of records displayed on each page.
Details: PHP code example for turning the previous page to the next page
,
ReInitSmarty ("demo/templates", "demo/templates_c", "demo/config", "demo/cache"); $ array_new = array (); $ SQL = "select * from news limit $ offset, $ pagesize"; $ res = mysql_query ($ SQL); while ($ row = mysql_fetch_assoc ($ res )) {$ array_new [] = $ row;} // var_dump ($ array_new); $ smarty-> assign ("array_new", $ array_new ); $ smarty-> display ("news. tpl "); $ SQL =" select count (*) as total from news "; $ result = mysql_query ($ SQL ); // total number of records $ row = mysql_fetch_assoc ($ result); $ total_rows = $ row ['total']; $ total_page = ceil ($ total_rows/$ pagesize ); echo 'homepage '; // when the first page is not displayed, if ($ page> 1) {echo 'previous page'; echo '';} // the next page if ($ page <$ total_page) {echo 'next page '; echo '';} echo 'Last page' is not displayed at the end of the page ';
The above section details the implementation of PHP code examples for turning pages on the next page of the previous page. For more information, see other related articles in the first PHP community!