Pagination of templates in PHP

Source: Internet
Author: User
Processing of pagination of templates in PHP, reading the processing of pagination of templates in PHP, it is relatively simple to process pagination when PHP code and html code are mixed in common php development, it can also be constructed as a function. Recently, the Pear: DB + Smarty structure is used in development. Therefore, if the template is paginated and the page cannot be operated directly, you need to generate the score "> <LINKhref =" http: //

When PHP code and html code are mixed in normal php development, it is relatively simple to process pages. you can also build them into functions. Recently, the Pear: DB + Smarty structure is used in development. Therefore, if you want to paging the template, you should consider generating a paging string because you cannot directly operate the page.

Because it is a three-tier structure, the class library --> PHP call --> template form, all the data processing is in the class library, so paging control is carried out in the PHP call, the template parses the call results in a complex way. Let's look at the paging code in PHP calls:

--------------------------------------------------------------------------------
/**
* File: Type. php
* Function: displays books under a category.
* Author: heiyeluren
**/

// Contains public files, including class libraries
Require_once ("include. php ");

// Instantiate the operation object
$ Type = new CTypes ();

// Number of records per page
Define ("PAGE_SIZE", 10 );

// GET the variable submitted by GET
$ TypeID = $ tid? $ Tid: intval ($ _ REQUEST ['tid']);

// Total number of books
$ BookTotal = $ Type-> getBookTotal ($ TypeID );

/* Display the core by page */
// Obtain the total number of pages
$ PageCount = ($ BookTotal/PAGE_SIZE );
// Current page number
If (isset ($ _ GET

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.