Smarty simple pagination Implementation method, Smarty pagination Implementation _php Tutorial

Source: Internet
Author: User

Smarty simple pagination Implementation method, Smarty paging implementation


The example of this paper describes the implementation of Smarty simple paging, shared for everyone to reference. The implementation method is as follows:

The following is the template of the Smarty code, with Smarty simple to enter the relevant variables on the line, very simple, but also in the PHP code to pass the page this parameter. I think this is very good, very simple. I'm more and more fond of using smarty.

The PHP code is as follows:
Copy the Code Code as follows: {if $pageCount > 1}
{foreach item=i from= $pagerList}
{if $pageNum eq $i}
{$i}
{Else}
{$i}
{/if}
{/foreach}
{if $pageNum eq 1}
Previous page
{Else}
Previous page
{/if}
{if $pageNum eq $pageCount}
Next page
{Else}
Next page
{/if}
{if $pageNum eq 1}
Home
{Else}
Home
{/if}

{if $pageNum eq $pageCount}
Last page
{Else}
Last page
{/if}
{/if}
(Total {$pageCount} page)

Here just give a thought, actually the pagination is not so complicated.

I hope this article is helpful to everyone's PHP programming.


How does PHP achieve the digital paging effect? How did you call Smarty? How to use PHP code to cycle pages?

There is a PHP system I see he is using the smarty, you can refer to the next
Ecshop
Mall program, I also intend to learn, this year began to try to do a system, give Smarty

Smarty Paging problem

The first method:
The idea is to take two parts of the data according to the page number, such as removing the first 90, then removing the first 100, then comparing the difference between the two results.

In the case of 300,000 records, if only 100 pages (results have 10,000 records), it takes about 1.5. If the index is well built, it's about 1 minutes.

SELECT * From//This sentence cannot be modified because it is read from the result, so it must be used *
(select Top @h_count (@filedlist) from @tableName ...) as big//Take out record of qualifying upper limit
where
Big.guid//Here is the key to filter out duplicate records from the lower limit results according to the primary key (leaving only different data, that is, intersection)
Not in
(select Top @l_count GUID from @table ...) Lower
Order @orderby//original format, here only reserved after the order, should be preserved after all, including gruopby or something

Functions like this:
public string Makesqlpager (String Sourcesql,int pageIndex)
{
Use default page size
String orderbystr=sourcesql.substring (Sourcesql.tolower (). IndexOf ("Order by");
int Index=sourcesql.tolower (). IndexOf ("select");
String bigres= "(" + Sourcesql.insert (index+6, "Top" + ((pageindex+1) *_pagesize). ToString () + "") + ") as big";
String smallres= "(" + Sourcesql.insert (index+6, "top" + (pageindex*_pagesize). ToString () + "") + ")";
Return "SELECT * from" +bigres+ "where Big.guid not in" +smallres+ "" +ORDERBYSTR;
}

This method can also be improved, that is, the second time the filter is filtered from the results of the first one.

The second method:
Qiatouquwei, the program hasn't been written yet.
SELECT * FROM
(
SELECT TOP * FROM
(
SELECT TOP 100000 * from Pagetest ORDER by Regt ASC
) as a
ORDER by Regt Desc
) as B
ORDER by Regt ASC

It's been tested for about 29 seconds.

Comparison:
The first method is inefficient, guessing because multiple cycles are needed to compare time complexity to a higher degree. For example, the response time of this method is very much related to the page number obtained.
The second method is acceptable, ... Remaining full text >>

http://www.bkjia.com/PHPjc/901286.html www.bkjia.com true http://www.bkjia.com/PHPjc/901286.html techarticle Smarty Simple Pagination implementation method, Smarty pagination implementation of this article describes the Smarty simple pagination implementation method, share to everyone for your reference. The implementation is as follows:

  • 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.