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 ^