Php paging encountered a problem. I just learned php and downloaded a video tutorial in php100. But according to the paging demo described in section 13th, I found that an error occurred while running. Why can I analyze the problem? The database table is "test" with the following fields: id, name, and sex. run the following demo to check the content on the first page, but click the next page without turning the page. The url is localhostbbs2page. php? Page2, and then click the php paging problem
I just learned php and downloaded a video tutorial in php100. But according to the paging demo described in section 13th, I found that an error occurred while running. Why can I analyze the problem? The database table is "test" with the following fields: id, name, and sex. run the following demo to check the content on the first page, but click the next page without turning the page. The url is http: // localhost/bbs2/page. php? Page = 2. click http: // localhost/bbs2/page. php on the next page? Page = 2 & page = 2; this address is incorrect. it should be http: // localhost/bbs2/page. php? Page = 3.
HTML code
". ($ Totle? ($ Firstcount + 1): 0 )."-". Min ($ firstcount + $ displaypg, $ totle )."A total of $ totle records "; // if there is only one page, the function will jump out: if ($ lastpg <= 1) return false; $ pagenav. = "homepage"; if ($ prepg) $ pagenav. = "previous page"; else $ pagenav. = "previous page"; if ($ nextpg) $ pagenav. = ""; else $ pagenav. = "back page"; $ pagenav. = "Last page"; // The drop-down Jump List. all pages are displayed cyclically: $ pagenav. = "to\ N "; for ($ I = 1; $ I <= $ lastpg; $ I ++) {if ($ I = $ page) $ pagenav. ="$ I\ N "; else $ pagenav. ="$ I\ N ";}$ pagenav. ="Page, total $ lastpg page ";} include (" conn. php "); $ result = mysql_query (" SELECT * FROM 'test "'); $ total = mysql_num_rows ($ result); // call pageft (), 10 messages are displayed on each page (this parameter can be omitted when the default value is 20). the URL on this page is used (default value, so this parameter is omitted ). _ PAGEFT ($ total, 5); echo $ pagenav; $ result = mysql_query ("SELECT * FROM 'test' limit $ firstcount, $ displaypg "); while ($ row = mysql_fetch_array ($ result) {echo"". $ Row [name]." | ". $ row [sex] ;}?>
------ Solution --------------------
This tutorial is really harmful, so unreliable. Why don't you find the source code on the Internet and change it?
I haven't seen $ _ GET ['Page'] for a long time. the words required for the LIMIT pages
------ Solution --------------------
PHP code
$ NowPage = is_numeric ($ _ GET ['Page'])? $ _ GET ['Page']: 1; // The current page $ displaypg = 5; // five entries per page; firstcount = ($ nowPage-1) * $ displaypg; $ result = mysql_query ("SELECT * FROM 'test' limit $ firstcount, $ displaypg ");
------ Solution --------------------
If you do not flip the page, your page does not get
This paging program is sufficient for thunderpeople
Too difficult
Write so big
It will not be a problem if it is removed in half.
------ Solution --------------------
Discussion