If you're pulling against a competant database, use the LIMIT SQL key word to limit your matches to a range. I
believe you can specify a starting point and a number of records to retrieve. So, modify your CGI to accept an additional argument or two (say, 'start' and 'number'), and on the page, if there are additional records to retrieve, provide a 'next' link with a 'start' value of start+number. Your SQL statement would then look something like this:
$sth = $dbh->prepare('SELECT ... FROM ... WHERE ... LIMIT ?,?') or die
+ "...";
$sth->execute(..., param('start') || 0, param('number') || 10) or die
+"...";
Make sense?
If your SQL database doesn't let you limit queries like that, have it pull everything into, say, an array, and just deal with an array slice that represents the information you want:
my $start = param('start') || 0;
my $num = param('number') || 10;
@results = $sth->execute(...);
@actual = @results[$start..($start+$num)]; # limit them
my $more_to_do = 1 if defined $results[$start + $num + 1];
my $less_to_do = 1 if $start;
print_previous_link if $less_to_do;
print_results(@actual);
print_next_link if $more_to_do;
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.