Markstar
New Member
- Messages
- 45
- Reaction score
- 0
- Points
- 0
Hi,
I would like to allow visitors of my website to "turn the page" where there are n news items per page. Implementing the "Next " button/link is easy, but I struggle to get the "Previous" button/link to work.
Here is an example with 3 items per page:
news item # (nitem FROM news)
...
16 // previous previous page
15
14
13 // first item of previous page (13-11)
12
11
10 // first item of current page (items 10 - 8)
9
8
7 // first item of next page (that's easy)
6
...
My problem was that nested queries didn't work with LIMITs and I would really like to get this with one SQL-statement and not have to go through a temporary result list in PHP.
Thank you for your time!
I would like to allow visitors of my website to "turn the page" where there are n news items per page. Implementing the "Next " button/link is easy, but I struggle to get the "Previous" button/link to work.
Here is an example with 3 items per page:
news item # (nitem FROM news)
...
16 // previous previous page
15
14
13 // first item of previous page (13-11)
12
11
10 // first item of current page (items 10 - 8)
9
8
7 // first item of next page (that's easy)
6
...
My problem was that nested queries didn't work with LIMITs and I would really like to get this with one SQL-statement and not have to go through a temporary result list in PHP.
Thank you for your time!