When you use a template, you encounter a problem: it is cumbersome to display paging information, and n multiple templates have paging blocks.
For example:
---Total 20 records, current 3/5 page first prev Next last GO-----
The first to encounter this problem of friends, in the consideration of solving this problem seems to be in the idea of PHP, consider how to use PHP to achieve, but no matter how you design after the design of two scenarios
1, using nested loops to achieve
2, with more than n judgment to engage in
But in the end it is more troublesome, and parsing is the use of server-side resources.
You might want to use JavaScript instead of your php!!!! in a different way. , so you can reduce the amount of PHP script code, but also to resolve the paging work to the client itself. But JavaScript can be tricky to debug.
The most important thing is to simplify the page display when the parsing template encounters pain.
The following template is parsed with a ITX template tool that supports pear.
which And Represents a block, {RecordCount} This similar string is a variable.
----------------List.tpl---------------------
Copy CodeThe code is as follows:
Other HTML code
Other HTML code
--------------------Page.js------------
---------------Total 20 records, current 3/5 page first prev Next last GO-------------------
RecordCount = 20;
Show = 20
PageCount = 5;
Pagenow = 3;
Pagestr = "Page=_page_";
document.write (Showlistpage (RecordCount, Show, PageCount, Pagenow, pagestr));
function ShowListPage0 (RecordCount, Show, PageCount, Pagenow, pagestr) {
if (pagecount<1) PageCount = 0;
if (pagenow<1) Pagenow = 0;
str = ' ";
return str;
}
function Pagego0 (PAGEGO,PAGENOW,PAGECOUNT,PAGESTR) {
if (pagego>=1 && pagego<=pagecount && pagenow!=pagego)
window.location = Pagestr.replace ("_page_", Pagego);
}
In addition, this method, even without a template, can also be used, as well as a good paging solution, as long as the {RecordCount} this similar string with the value of the variable to replace it.
http://www.bkjia.com/PHPjc/319798.html www.bkjia.com true http://www.bkjia.com/PHPjc/319798.html techarticle when you use a template, you encounter a problem: it is cumbersome to display paging information, and n multiple templates have paging blocks. For example:---A total of 20 records, the current 3/5 page first prev ...