PHP simplest MySQL paging display method

Source: Internet
Author: User

<?
$ Db = mysql_connect () or die ("unable to connect to MySQL ");
Mysql_select_db ("") or die ("unable to Open Database ");
If (! Isset ($ page ))
$ Page = 1; // if no page parameter is set, page is automatically set to 1.
$ Pageno = 5; // set the number of entries displayed on each page
$ Pagestart = ($ page-1) * $ pageno;
$ SQL = "select * from book order by ID DESC limit $ pagestart, $ pageno ";
$ Result = mysql_query ($ SQL _string );
$ Numrows = mysql_num_rows ($ result );
?>
/*************************************** ********************************
Display content
**************************************** *******************************/
<? // Display data by PAGE
$ Up = $ page-1;
$ DN = $ page + 1;
If ($ page> 1)
{
Print "<center> <br> <a href = $ php_self? Page = $ up> previous page </a> ";
}
Else
{
Echo "<center> <br> previous page ";
}
If ($ pageno> $ numrows)
{
Print "next page ";
}
Else
{
Print "<a href = $ php_self? Page = $ DN> next page </a> | n ";
}
Mysql_close ($ dB );
?>

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.