How to simplify the paging code in the PHP template page

zhaozj2021-02-12  188

-------------------------------------------------- The article is mainly written for the "use of templates", but this method is suitable for any occasion, which is a better solution in any case -------------- ---------------------------------- When using the template, you will encounter such a problem: display paging information Tatose trouble, N multiple templates have a page block. For example: --- Total 20 records, current 3/5 page Home Previous Next Last page Go ----- First encounter this problem Taoist friends, when considering solving this problem, it seems like Playing a PHP's idea, how to use PHP to achieve, but no matter how you design, it is designed to be two options 1, with a nesting loop to achieve 2, with multiple judgment, but ultimately trouble, but also more troublesome, and The resource of the server is used when parsing.

Take a way to replace your PHP with JavaScript! ! ! ! This reduces the code amount of the PHP script, and you can hand over the work of the paging paging to the client. However, JavaScript debugging may be more troublesome. The most important thing is that when you simplify the paging display, parsing the template encountered. Here is a template parsed by a ITX template tool that supports PEAR. Where represents a block, {recordcount} This similar string is a variable.

---------------- List.tpl ------------------- // Other HTML code