Php paging functions

Source: Internet
Author: User
Copy the code classajaxpage {var $ resuvar $ anchors; var $ total ;...

The code is as follows:
Class ajaxpage {
Var $ result;
Var $ anchors;
Var $ total;
Var $ db;
Var $ webpage effect p/jsp.html target = _ blank> jsp tutorial agination;
Function _ construct ($ qry, $ starting, $ recpage, $ jspagination)
{
$ This-> db = & $ globals ['DB'];
$ This-> jspagination = $ jspagination;
$ Rst = $ this-> db-> query ($ qry );
$ Numrows = $ this-> db-> num_rows;
$ Qry. = "limit $ starting, $ recpage ";

$ This-> result = $ this-> db-> get_results ($ qry, array_a );

$ Next = $ starting + $ recpage; // the number next time end
// $ Var = (intval ($ numrows/$ recpage)-1) * $ recpage;
$ Page_showing = intval ($ starting/$ recpage) + 1; // the str shows on the page bar
$ Total_page = ceil ($ numrows/$ recpage); // total page
If ($ numrows % $ recpage! = 0 ){
$ Last = (intval ($ numrows/$ recpage) * $ recpage;
} Else {
$ Last = (intval ($ numrows/$ recpage)-1) * $ recpage;
}
$ Previous = $ starting-$ recpage;
$ Anc ="
    ";
    If ($ previous <0 ){
    $ Anc. ="
  • First
  • ";
    $ Anc. ="
  • Previous
  • ";
    } Else {
    $ Anc. ="
  • Jspagination (0); '> first
  • ";
    $ Anc. ="
  • Jspagination ($ previous); '> previous
  • ";
    }

    ############### If you dont want the numbers just comment this block ############## #

    $ Norepeat = 3; // no of pages showing in the left and right side of the current page in the anchors
    $ J = 1;
    $ Anch = "";
    For ($ I = $ page_showing; $ I> 1; $ I --){
    $ Fpreviouspage = $ I-1;
    $ Page = ceil ($ fpreviouspage * $ recpage)-$ recpage;
    $ Anch ="
  • Jspagination ($ page); '> $ fpreviouspage
  • ". $ Anch;
    If ($ j = $ norepeat) break;
    $ J ++;
    }
    $ Anc. = $ anch;
    $ Anc. ="
  • ". $ Page_showing ."
  • ";
    $ J = 1;
    For ($ I = $ page_showing; $ I <$ total_page; $ I ++ ){
    $ Fnextpage = $ I + 1;
    $ Page = ceil ($ fnextpage * $ recpage)-$ recpage;
    $ Anc. ="
  • Jspagination ($ page); '> $ fnextpage
  • ";
    If ($ j = $ norepeat) break;
    $ J ++;
    }

    ######################################## ####################
    If ($ next> = $ numrows ){
    $ Anc. ="
  • Next
  • ";
    $ Anc. ="
  • Last
  • ";
    } Else {
    $ Anc. ="
  • Jspagination ($ next); '> next
  • ";
    $ Anc. ="
  • Jspagination ($ last); '> last
  • ";
    }
    $ Anc. ="
";
$ This-> anchors = $ anc;

$ This-> totalstr = "page: $ page_showingOf$ Total_page. total records found: $ numrows ";
}
}



Permanent address:

Reprint at will ~ Please bring the tutorial URL ^

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.