Since retrieving the entire data set every time through is grossly inefficient, you likely will end up doing one or both of two things: retrieving just the rows you need or caching the results someplace.
Many dialects of SQL will let you specify the rows you need. For instance Mysql has a LIMIT clause:
SELECT * FROM bannerlog.log LIMIT 100, 100;
which says return only the rows starting at the 101st row and going 100 rows from there.
If we were saving state using HTML form variables and using CGI::Request to fetch form parameters (using mod_perl, I'd use Apache::Request) our code would then end up something like:
use CGI::Request; my $req = new CGI::Request; my $rows_per_page = 100; my ($first_row, $command) = map { $req->param($_) } qw/first_row command/; if ($command eq 'previous_page') { $first_row -= $rows_per_page; $first_row = 0 if $first_row < 0; } elsif ($command eq 'next_page') { $first_row += $rows_per_page; } my $result = Database->get_results($query, $first_row); Display->results($result, $first_row);
good luck!
In reply to Re: Database Data Page
by cleverett
in thread Database Data Page
by artist
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |