views:

35

answers:

2

I have 1000 rows of data but need to only display 100 rows at a time. I would like navigation buttons (like on google next, prev) to go thought the groups of 100

My C cgi application runs and exits every new query, so it can't save states.

Question is: What is the most efficient way to save the current state of the OFFSET, so I can navigate back and forth through rows of 100 in the SQL db?

Any help is appreciated. Thanks.

+2  A: 

Very confusing way to ask this, but...

Your 'page' has 100 items, so simply pass a GET variable to the next page ?page=1 Then you use OFFSET = page * 100

Evert
(Edited question.) How does the next and previous navigation save it's current state, to pass page=1, then the next time it is clicked page=2 etc?
Tommy
The trick is, you don't do it in the SQL. When you generate the page you *know* what the current page is, so adding 1 gets you the next page.You don't maintain the page-state at all on the server, just use url variables and let the browser maintain it.
Evert
+1  A: 

Offset is usually determined by resultsPerPage, and pageId. It would be figured server-side, and those values would be passed through the URL or posted to the server.

Jonathan Sampson