Questions about paging in php and mysql

Source: Internet
Author: User
For paging issues in php and mysql, use php to extract information from mysql and display the code in pages: & lt; tablewidth = & quot; 90% & quot; border = & quot; 0 & quot; align = & quot; center & quot; & gt; & php and mysql paging problems
Use php to extract mysql information and display it by page.
Code:











































$ Mylink = mysql_connect ("localhost", "root", "998121021 ");Mysql_select_db ("liuyan", $ mylink );$ SQL = "select * from data order by time ";$ Result = mysql_query ($ SQL );$ Message_count = mysql_num_rows ($ result );Echo $ message_count;$ I = $ message_count-1;$ Page_size = 2;$ Page_count = ceil ($ message_count/$ page_size );Echo $ page_count;If ($ page <1) $ page = 1;If ($ page> $ page_count) $ page = $ page_count;$ Offset = ($ page-1) * $ page_size;$ Sql1 = "select * from data order by time limit $ offset, $ page_size ";$ Result1 = mysql_query ($ sql1 );While ($ myarray = mysql_fetch_array ($ result1 )){Extract ($ myarray );Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';Echo' ';$ I --;}?>
'. ($ Message_count-$ I). "floor ".''. "User name:". $ name .''. ''. $ Email .'
'. $ Time .'
'. $ Words .'
'.' '.'


$ Pre_page = $ page-1;
$ Next_page = $ page + 1;
Echo $ page;
$ PATH_INFO = pathinfo ("http: // localhost: 250/myphp programming/message board page display. php ");
If ($ page = 1)
{
Echo "First Page Previous Page "."";
}
Else
{
Echo "Page 1 ";
Echo "";
Echo "previous page ";
}
Echo "";
If ($ page = $ page_count)
{
Echo "the last page on the next page ";
}
Else
{
Echo "next page ";
Echo "";
Echo "last page ";
Echo $ page_count;
}

?>

The pagination part of the code is incorrect. The path_info () function in the book is used incorrectly and I do not know how to use it. "http: // localhost: 250/myphp programming/message board page display. php "is my file path. On the "next page", "last page", "first page", and "previous page", how should I write the link?

------ Solution --------------------
$ Page = $ _ GET ['Page']? $ _ GET ['Page']: 1; // add this sentence.

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.