PHP develops the home page paging function of a simple book lending system
When the main page is completed, the database data needs to be displayed through SQL statements
You need to use the paging function to display it. After all, the number displayed on the first page is limited.
We set 5 pieces of data to be displayed on each page
$pagesize=5;
To obtain the id, you need to sort it in reverse order. The book title category is in Chinese, and the urldecode() function is needed to convert the Chinese into an encoded form.
Get the total number of queried data, calculate the total number of pages, and then judge the current page. When the current page is less than the first page, the first page is displayed. When the current page number is greater than the total number of pages, the total number is displayed. Pages Pages.
Determine which piece of data to start displaying on each page.
$pagecount) //当前页数大于总页数时显示总页数 { $pageno=$pagecount; } $startno=($pageno-1)*$pagesize; //每页从第几条数据开始显示 ?>
SELECT queries out the statements in the database and then displays them in a loop:
Finally, the functions of clicking the homepage, previous page, next page, and last page are displayed.
If the current page is the first page, only the home page and the previous page will be displayed.
When the current page is the total number of pages, the homepage and previous page are displayed as links.
The rest are displayed as normal added links
首页 | 上一页 | 下一页 | 末页 首页 | 上一页 | 下一页 | 末页 首页 | 上一页 | &pageno=" class="forumRowHighlight">下一页 | 末页 页次:/页 共有条信息