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; & lt ;? Php & nbsp; $ mylinkmysql_connect (& quot; localho 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'
'. ($ Message_count-$ I). "floor ".' | ';Echo'
'. "User name:". $ name .' | ';Echo'
'. ''. $ Email .' | ';Echo'
';Echo'
';Echo'
'. $ Time .' | ';Echo'
';Echo'
'. $ Words .' | ';Echo'
';Echo'
';Echo'
'.' '.' | ';Echo'
';$ I --;}?>
$ 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.