Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

hi! my teammates and i are working on a report that will generate several pages of a certain table. and for every page, only a maximum number of table entries can be displayed. the succeeding page numbers are displayed below and the user can click on them to go to that page....like so : Page 1 2 3 4 5 6 7... my question: HOW DO WE CODE THE PAGING PART? we really need advice. thanks!

Replies are listed 'Best First'.
Re: paging in perl
by merlyn (Sage) on Sep 18, 2000 at 07:11 UTC
Re: paging in perl
by chromatic (Archbishop) on Sep 18, 2000 at 06:59 UTC
    I can't find a link to the previous discussion on this, but the simplest answer is, pass an offset as a hidden field in your page. If you're pulling rows from a database, the SQL 'LIMIT' command (or your database's equivalent) will come in handy.

    If you're looping through an array, just do what comes naturally.

    my $offset = $q->param('offset'); $offset ||= 0; print "<p>$_</p>" foreach (@results[ $offset .. ($offset + $max) ]);
    That's untested code, by the way.
Re: paging in perl
by Anonymous Monk on Sep 18, 2000 at 07:11 UTC
    thanks, o wise one Ü ---- the anonymous monk who asked the question Ü