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
Region code |
Region name |
Parent code |
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"
{$ V [0]} |
{$ V [1]} |
{$ V [2]} |
";}// Display?>
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
Region code |
Region name |
Parent code |
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"
{$ V [0]} |
{$ V [1]} |
{$ V [2]} |
";}// Display?>
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