Details: PHP code example for turning the previous page to the next page

Source: Internet
Author: User
Tags php code examples
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!

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.