in reply to Next 10....
Make sense?$sth = $dbh->prepare('SELECT ... FROM ... WHERE ... LIMIT ?,?') or die + "..."; $sth->execute(..., param('start') || 0, param('number') || 10) or die +"...";
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;
|
|---|