scripting

How do I implement a custom "paging" script for a variable number of items?

A very common problem in web programming is to implement paging. Paging is required whenever there is an undefined amount of items (usually queried from a database) with a maximum amount of items to be displayed on one page. If there is more than one page, there must be a possibility to navigate through these pages while each page displays the desired amount of items. An example will demonstrate the problem: State: - You have a category containing 23 products to be displayed in the category overview of your webshop - A single page should display a maximum of 8 pages for design and usability reasons Now we have to calculate the number of pages, the number of products to display per page and display everything to the user. This case will result in 3 pages: Page 1 will display the items 1-8, Page 2 will display the pages 9-16 and Page 3 will display the items 17-23. Please show a general algorithm for this problem.
Subscribe to scripting