Simple paging type

Source: Internet
Author: User
Simple paging is a simple and easy-to-use paging class. You only need to add or modify one sentence in your original program, and then paste the code paging. phpPHPcode & lt ;? PhpclassPaging {publicstatic $ count0; publicstatic $ size0; publicstatic $ page0; staticfunctio simple paging class
This is a simple and easy-to-use paging class. You only need to add or modify one sentence in your original program.
Post code first
Paging. php
PHP code
  
  1, 'prve' => $ page> 1? $ Page-1: 1, 'next' => $ page <$ count? $ Page + 1: $ count, 'end' => $ count,); foreach ($ d as $ k => $ v) {$ _ GET ['Page'] = $ v; $ tpl = str_replace ($ k, http_build_query ($ _ GET), $ tpl);} echo $ tpl ;}}

You usually have statements like this.
$ SQL = ".....";
$ Rs = mysql_query ($ SQL );
Or
$ Rs = mysql_query ("select ....");


You only need to change
Include 'Paging. php ';
$ Rs = paging: prepare ($ SQL, number of lines per page );
Write to the place where paging entries need to appear
Paging: bar ();

It's easy!


------ Solution --------------------
Front-row worship mode.
This is the first time I have seen it.
$ SQL = preg_replace ('/select \ s/I', '$ 0SQL_CALC_FOUND_ROWS', $ SQL). "limit $ pageon, $ pagesize ";

SQL also uses preg_replace ......
------ Solution --------------------

Thanks for sharing. it is really convenient and easy to use. I learned.
------ Solution --------------------
Discussion
This is a simple and easy-to-use paging class. You only need to add or modify one sentence in your original program.
Post code first
Paging. php
PHP code
Class Paging {
Public static $ count = 0;
Public static $ size = 0;
Public static $ page = 0;
Static function prepare ($ SQL, $ ......

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.