A complete example of the Smarty paging implementation method is provided. The Smarty paging implementation method is a complete example. The smarty paging instance in this article describes the implementation method of Smarty paging. For your reference, see the following: the first part is the php file: the complete implementation of the Smarty paging method instance and the smarty paging instance.
This article describes how to implement Smarty paging. We will share this with you for your reference. The details are as follows:
The first part is the php file:
<? Phprequire ("include. php "); // contains the require 'Conn in the smarty configuration section. php '; // contains the database configuration section $ pagesize = 10; // sets the number of data displayed per page $ url = $ _ SERVER ['request _ URI']; $ url = parse_url ($ url); $ url = $ url ['path']; $ SQL = "SELECT * FROM 'WP _ links '"; $ db_list = mysql_query ($ SQL); $ num = mysql_num_rows ($ db_list); // Total statistics $ pages = $ num/$ pagesize; $ pages = ceil ($ pages ); // find the total number of pages required to display if ($ _ GET ['Page']) {$ pageval =$ _ GET ['Page']; $ page = ($ pageval-1) * $ pagesize;} if ($ Num> $ pagesize) {if (! Isset ($ pageval) $ pageval = 1;} if ($ pages = 1) {// if the total page has only one page, replace the tag of "previous page" and "next page" with null. $ Pageup = ""; $ pagedown = "";} else {switch ($ pageval) {case 1: {$ pageup = "homepage"; $ pagedown = "next page "; break;} default: {$ pageup = "previous page"; $ pagedown = "next page"; break;} case $ pages: {$ pageup = "previous page "; $ pagedown = "Last page"; break ;}}$ smarty-> assign ("pageconfig", $ pageconfig ); // ================================================ =============$ SQL _list = "SELECT * FROM 'WP _ links 'LIMIT $ page, $ pagesize "; // This controls the number of data displayed. $ db_list_list = mysql_query ($ SQL _list); while ($ row = mysql_fetch_array ($ db_list_list) {$ page_list [] = array ("id" => $ row ['link _ id'], "url" => $ row ['link _ url'], "name" => $ row ['link _ name']); // revalue the query content in the database} $ pageconfig = "current $ pageval page, total $ pages page"; $ smarty-> assign ("pageconfig", $ pageconfig ); $ smarty-> assign ("pageup", $ pageup); $ smarty-> assign ("pagedown", $ pagedown); $ smarty-> assign ("title ", $ page_list); $ smarty-> display ("index.htm");?>
The template is written as follows:
| id |
url |
name |
{section name=list loop=$title}
| {$title[list].id} |
{$title[list].url} |
{$title[list].name} |
{/section}
{$pageup}{$pagedown}{$pageconfig}