Php paging query-php paging code

Source: Internet
Author: User
By referencing the page. class. php paging tool, php paging queries are much easier to write. By referencing the page. class. php paging tool, php paging queries are much easier to write;

The following is the php paging code.

1. First, you must have the following content:


    
     Untitled DocumentPaging


 
  Query ($ SQL); // The default value is 1. you can leave foreach ($ arr as $ v) {echo "empty"


 
 ";}?> 
  
Region code Region name Parent code
{$ V [0]} {$ V [1]} {$ V [2]}

Include ("page. class. php "); // check the total number of items $ sz =" select count (*) from chinastates "; $ az = $ db-> Query ($ sz); // 1. create object $ page = new page ($ az [0] [0], 10); // generally, only two parameters are written, the total number of items in the first data // take two indexes 0: First take index 0 Two-dimensional array, get one array, then take index 0 // second parameter, display 10 items $ SQL = "select * from chinastates ". $ page-> limit; // 2. directly splice the limit in $ page (paging class) after the SQL statement to complete the paging $ arr = $ db-> Query ($ SQL ); // The default value is 1, which can be left empty.

3. output:

 Fpage (); // The fpage () method in the paging object?>

Total code:


    Untitled DocumentPaging query
 
  Query ($ aall); // call SQL and return an array, $ page = new page ($ arr [0] [0], 10); // page class object, 10 $ SQL = "select * from chinastates" is displayed on each page ". $ page-> limit; // paging Query. the page class calls limit $ ar = $ db-> Query ($ SQL); // executes and returns an array (data) foreach ($ ar as $ v) // traverse {echo" 
   ";}// Display?> 
  
Region code Region name Parent code
{$ V [0]} {$ V [1]} {$ V [2]}

Fpage (); // directly output the fpage () in the page class (output page information)?>

 

$ Tj = "1 = 1"; // conditional constant variable if (! Empty ($ _ GET ["area"]) // checks whether the passed data is null {$ r = $ _ GET ["area"]; // to prevent the double quotation marks from being conflicted, the variable $ tj = "areaname like '% {$ r} %'"; // The condition is changed}

The query statement also needs to be changed:

$ Aall = "select count (*) from chinastates WHERE {$ tj}"; // query all data $ SQL = "select * from chinastates WHERE {$ tj }". $ page-> limit; // query by page. the page class calls limit.

Output:

Fpage (); // directly output the fpage () in the page class (output page information)?>

:

    
     Untitled DocumentPaging


 
  Query ($ SQL); // The default value is 1. you can leave foreach ($ arr as $ v) {echo "empty"


 
 ";}?> 
  
Region code Region name Parent code
{$ V [0]} {$ V [1]} {$ V [2]}

Include ("page. class. php "); // check the total number of items $ sz =" select count (*) from chinastates "; $ az = $ db-> Query ($ sz); // 1. create object $ page = new page ($ az [0] [0], 10); // generally, only two parameters are written, the total number of items in the first data // take two indexes 0: First take index 0 Two-dimensional array, get one array, then take index 0 // second parameter, display 10 items $ SQL = "select * from chinastates ". $ page-> limit; // 2. directly splice the limit in $ page (paging class) after the SQL statement to complete the paging $ arr = $ db-> Query ($ SQL ); // The default value is 1, which can be left empty.

3. output:

 Fpage (); // The fpage () method in the paging object?>

Total code:


    Untitled DocumentPaging query
 
  Query ($ aall); // call SQL and return an array, $ page = new page ($ arr [0] [0], 10); // page class object, 10 $ SQL = "select * from chinastates" is displayed on each page ". $ page-> limit; // paging Query. the page class calls limit $ ar = $ db-> Query ($ SQL); // executes and returns an array (data) foreach ($ ar as $ v) // traverse {echo" 
   ";}// Display?> 
  
Region code Region name Parent code
{$ V [0]} {$ V [1]} {$ V [2]}

Fpage (); // directly output the fpage () in the page class (output page information)?>

 

$ Tj = "1 = 1"; // conditional constant variable if (! Empty ($ _ GET ["area"]) // checks whether the passed data is null {$ r = $ _ GET ["area"]; // to prevent the double quotation marks from being conflicted, the variable $ tj = "areaname like '% {$ r} %'"; // The condition is changed}

The query statement also needs to be changed:

$ Aall = "select count (*) from chinastates WHERE {$ tj}"; // query all data $ SQL = "select * from chinastates WHERE {$ tj }". $ page-> limit; // query by page. the page class calls limit.

Output:

Fpage (); // directly output the fpage () in the page class (output page information)?>

:

}

For more php paging queries-php paging code articles, please follow the first PHP community

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.