Php object-oriented paging data display

Source: Internet
Author: User
Php fans will like a variety of object-oriented source code, which can be used out of the box in terms of calling. the data displayed in the HA paging is only available for small functional modules.

Php fans will like a variety of object-oriented source codes, which can be easily used for calling, however, for small functional modules, the source code is not mentioned much,

A few years later, Tom found that there is no good habit of commenting on the code. Alas, this is very lacking. while doing php tutorials, it is very lacking, but it is still explained by the source code.

Class page {
Private $ pagesize;
Private $ page;
Private $ total;
Private $ conn;
Private $ pagecount;
Public function _ construct ($ pagesize, $ page ){
$ This-> pagesize = $ pagesize;
$ This-> page = $ page;
}
Public function listinfo (){
If ($ this-> page = "" |! Is_numeric ($ this-> page )){
$ This-> page = 1; // The initial value assignment process.
}
$ This-> conn = mysql_connect ("localhost", "root ","");
Mysql_select_db ("user", $ this-> conn );
Mysql_query ("set names utf8 ");
$ SQL = mysql_query ("select count (*) as total from user_student", $ this-> conn );
$ Info = mysql_fetch_array ($ SQL );
If ($ this-> total = 0 ){
Echo "no content ";
} Else {
If ($ this-> total % $ this-> page = 0 ){

$ This-> pagecount = intval ($ this-> total/$ this-> pagesize );
} Else {
If ($ this-> total <= $ this-> pagesize ){
$ This-> pagecount = 1;
} Else {
$ This-> pagecount = ceil ($ this-> total/$ this-> pagesize );
}
}
}
}

}
?>

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.