Php paging function with parameter description-PHP source code

Source: Internet
Author: User
Ec (2); usage instructions on paging functions: #### retrieve paging functions #### Int $ HALT-whether or not the retrieval results are only divided into 1 page (10) display page number Int $ LRLIST-(display page number of page number-1) 2Int $ ECHOCNT-number of records displayed per page during retrieval Int $ paper-page number, pre-extracted: $ paper $ HTTP_GET_VARS [paper]; Varchar $ table-count script ec (2); script

Usage of paging functions:
#### Retrieve paging functions ####
Int $ HALT-whether the page number is displayed (1/0) when the search result is divided into only one page
Int $ LRLIST-(number of displayed page numbers-1)/2
Int $ ECHOCNT-number of records displayed per page during retrieval
Int $ paper-page number, pre-extracted: $ paper = $ HTTP_GET_VARS [paper];
Varchar $ table-data table name, with a pre-attached value: $ table = "db. table ";
Varchar $ where-search condition, with a value prefixed: $ where = "where field = 'value '";
Varchar $ enwhere-encode the original $ where twice and then submit it in GET Mode
Varchar $ splitstr-the output string of the page number. After executing the function, execute echo $ splitstr at the corresponding position;
You need to get the variable before calling the function:
$ Paper = $ HTTP_GET_VARS [paper];
$ Sumcnt = $ HTTP_GET_VARS [sumcnt];
$ Enwhere = $ HTTP_GET_VARS [enwhere];
Return (Varchar $ where)-Search Condition of the paging query statement
Note: This function calls the error handling function: nerror ($ error );

// Paging Function
Function splitlist ($ HALT, $ LRLIST, $ ECHOCNT, $ paper, $ table, $ where, $ page_id, $ userid ){
Global $ splitstr, $ sumcnt;
If ($ paper = "" | $ sumcnt = ""){
$ Query = "select count (*) as num from $ table $ where ";
$ Result = mysql tutorial _ query ($ query );
$ Row = mysql_fetch_array ($ result );
$ Sumcnt = $ row ["num"];
If ($ sumcnt = 0 ){
Nerror ("no news has been selected for this version! ");
}
$ Paper = 1;
}
$ Sumpaper = ($ sumcnt-$ sumcnt % $ ECHOCNT)/$ ECHOCNT;
If ($ sumcnt % $ ECHOCNT )! = 0) $ sumpaper + = 1;
If ($ sumpaper = 1 & $ HALT = 0) return ($ where );
$ Enwhere = base64_encode (base64_encode ($ where ));
If ($ LRLIST * 2 + 1) <$ sumpaper ){
If ($ paper-$ LRLIST) <2 ){
$ Tract = 1;
$ Sub = $ LRLIST * 2 + 1;
} Else if ($ paper + $ LRLIST) >=$ sumpaper ){
$ Tract = $ sumpaper-($ LRLIST * 2 );
$ Sub = $ sumpaper;
} Else {
$ Tract = $ paper-$ LRLIST;
$ Sub = $ paper + $ LRLIST;
}
} Else {
$ Tract = 1;
$ Sub = $ sumpaper;
}
$ Uppaper = $ paper-1;
$ Downpaper = $ paper + 1;
$ Startcnt = ($ paper-1) * $ ECHOCNT;
$ Where. = "limit $ {startcnt}, $ {ECHOCNT }";
If ($ tract> 1) {$ splitstr = "[<";}
Else $ splitstr = "[<";
For ($ I = $ tract; $ I <= $ sub; $ I ++ ){
If ($ I! = $ Paper) $ splitstr. = "". $ I ."";
Else $ splitstr. = "". $ I ."";
}
If ($ sub! = $ Sumpaper) $ splitstr. = "> ]";
Else $ splitstr. = "> ]";
Return ($ where );
}
?>

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.