Paging code solution in php

Source: Internet
Author: User
Paging code in php & lt; html & gt; & lt; head & gt; & lt; metahttp-equiv = & quot; Content-Type & quot; content = & quot; text/html; charset = gb2312 & quot; & gt; & lt; title & gt; paging code in Information php



Information


Include "SQL _class.php ";
$ Mysql = new Db_Mysql ();
$ Mysql-> dbConnect ();
// $ Error = new Script ();

$ PageSize = 2;
$ Page_string = "";
$ Totalpage = "";
If (isset ($ _ GET ['Page']) {
$ Page = intval ($ _ GET ['Page']);
}
Else {
$ Page = 1;
}
$ SQL = "select count (*) as amount from $ mysql-> table order by id desc ";
$ Result = mysql_query ($ SQL );
$ Amount = mysql_result ($ result, 0, "amount ");
If ($ amount ){
If ($ amount <$ pageSize ){
$ Totalpage = 1;
}
If ($ amount % $ pageSize ){
$ Totalpage = intval ($ amount/$ pageSize) + 1;
} Else {
$ Totalpage = $ amount/$ pageSize;
}
}
Else {
$ Totalpage = 1;
}
?>

Add message






































$ Select = "select * from $ mysql-> table limit ($ page-1) * $ pageSize), $ pageSize ";$ Num = mysql_query ($ select );Row 55th: while ($ info = mysql_fetch_array ($ num )){?> }If ($ page> 1 AND $ page <$ totalpage ){$ Page_string = "The current page is $ page | <a href =? Page = 1> page 1 </a> | <a href =? Page = ($ page-1)> Previous page </a> | <a href =? Page = ($ page + 1)> Next page </a> | <a href =? Page = $ totalpage> last page </a> ";}Else if ($ page <1 ){$ Page_string = "The current page is $ page | first page | previous page ";}Else if ($ page> $ totalpage ){$ Page_string = "The current page is $ page | next page | last page ";}?>
No. Message recipient Topic Content Date Edit Delete
"> "> Edit "> Delete

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.