Pagination in PHP

前端 未结 5 683
猫巷女王i
猫巷女王i 2020-12-02 02:31

I have a page that serves a list of files for users to download. There can be hundreds of files there, and I would like to break them down into multiple pages and give users

5条回答
  •  南方客
    南方客 (楼主)
    2020-12-02 03:32

    For someone that has never done anything like this it doesn't hurt to learn.

    In order to do this you are going to need to pass values through the url and have your sql script change based on the limit value passed in the url.

    Things to consider: SQL limit - This is the amount of results you will receive. Page number - This is the page of results that are returned. Sort - This is how the results are going to be returned in the pagination. page links - The list of pages. This is found by taking your result number, dividing by the limit and flooring the number.

    The hard part about creating pagination is making it extendible and able to be used with other lists of information such as comments or user lists.

提交回复
热议问题