• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Bear Bibeault
  • Knute Snortum
  • Liutauras Vilda
Sheriffs:
  • Tim Cooke
  • Devaka Cooray
  • Paul Clapham
Saloon Keepers:
  • Tim Moores
  • Frits Walraven
  • Ron McLeod
  • Ganesh Patekar
  • salvin francis
Bartenders:
  • Tim Holloway
  • Carey Brown
  • Stephan van Hulst

Need advice on structuring pagination  RSS feed

 
Ranch Hand
Posts: 180
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Guys

I am working on a pagination system for my webapp and its causing me alot of headaches at the moment.

The user can view upto 50 records per page. The URL query is like page=1, page=2 etc - To workout the the MIN and MAX values for the mysql LIMIT I multiply the page number by 50 which gives me the MAX amount for the LIMIT, to workout the MIN I minus 50 from the MAX amount. So the query for say page 3 would look something like this:

MAX: 50 x 3 = 150
MIN 150 - 50 = 100
SELECT * FROM table WHERE id='1' LIMIT 100, 150;

Now, I have two problems:

1. The user should be able to view the current set of records he is browsing, e.g. "Viewing 100 of 134 Orders" - How do I workout the current amount of records being viewed ? Iknow how to work out the max, I just use count(*) in mysql.

2. How can I determine whether the previous/next page links should be enabled or disabled ?

Please note that I am trying to avoid using any greedy methods of dealing with this issue (such as caching all the records) because the query is complex and there can potentially be ALOT of data in each table.

Before anyone suggests it, yes I have read the pagination FAQ.



.
.
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm not sure I understand your problem.

Can't you store information in a session about the number of records available and the number of the first on the current page?

How are these "previous/next" page links being generated?

Bill
 
Today you are you, that is turer than true. There is no one alive who is youer than you! - Seuss. Tiny ad:
RavenDB is an Open Source NoSQL Database that’s fully transactional (ACID) across your database
https://coderanch.com/t/704633/RavenDB-Open-Source-NoSQL-Database
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!