When a newbie asks a paging type, an output loop is displayed on the page.

Source: Internet
Author: User
Question: How can I solve a problem in the output loop display page of The paging class? & Lt ;? Phpclass & nbsp; PageClass & nbsp; {private & nbsp; $ total_record; // total record private & nbsp; $ page_size; // The number of page records. private & newbie's question: an output loop is displayed on pages. how can this problem be solved?

Class PageClass {
Private $ total_record; // total records
Private $ page_size; // Number of page Records
Private $ current_page; // current page
Private $ total_page_size; // total number of pages
Private $ page_url; // page url
Private $ page_start; // Start Page
Private $ page_stop; // end page
Public $ page_limit; // limit,
Function _ construct ($ total_record = 0, $ page_size = 1, $ current_page = 1, $ page_url ){
$ This-> total_record = $ this-> numeric ($ total_record );
$ This-> page_size = $ this-> numeric ($ page_size );
$ This-> current_page = $ this-> numeric ($ current_page );
$ This-> page_limit = ($ this-> current_page * $ this-> page_size)-$ this-> page_size;
$ This-> page_url = $ page_url;
If ($ this-> current_page <1 ){
$ This-> current_page = 1;
}

If ($ this-> current_page <0 ){
$ This-> current_page = 0;
}
$ Total_page_size = ceil ($ total_record/$ page_size );

If ($ this-> total_page_size <1 ){
$ This-> total_page_size = 1;
}
If ($ this-> current_page> $ this-> total_page_size ){
$ This-> crrent_page = $ this-> total_page_size;
}
$ This-> page_start = $ this-> current_page;
$ This-> page_stop = $ this-> current_page + 5;
If ($ this-> page_stop> $ this-> total_page_size ){
$ This-> page_stop = $ this-> total_page_size;
$ This-> page_start =$ this-> page_stop-5;
}
If ($ this-> page_start <1 ){
$ This-> page_start = 1;
If ($ this-> page_stop> $ this-> total_page_size ){
$ This-> page_stop = $ this-> total_page_size;
}

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.