Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
First of all, the hash is ALWAYS retrieved in a specific order, so we don't need to worry about that. I'm trying to get this to print the latest 20 images inserted into the DB on the first page (or page without a url_param) and apply a mathematical equation to figure out the proper range of each extra page.my $page = url_param('page'); my $top = $page* 20); my $bottom = $top - 20; if ($page ne "") { for ( grep defined($_), ( reverse keys %upload )[ $bottom .. $top ] ) +{ do this if url_param exists ... } else { for ( grep defined($_), (reverse keys %upload )[ 0 .. 19] ) { do this if on first page, without url_param ... }
I'm trying to accomplish something like:
page 1: latest 20 entries
page 2: 20 entries older than page 1
page 3: 20 entries older than page 2
page 4: 20 entries older than page 3
But the problem is, the equation isn't quite right because on some pages (other than the main page) it prints image 1 in it's range and on the next consecutive page it starts with image 1. It's using the same image on both pages.
Can anyone offer any advice?
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: mathematical equation
by sulfericacid (Deacon) on Jul 27, 2003 at 22:36 UTC | |
by sauoq (Abbot) on Jul 28, 2003 at 06:59 UTC | |
|
Re: mathematical equation
by fergal (Chaplain) on Jul 27, 2003 at 23:00 UTC | |
|
Re: mathematical equation
by sauoq (Abbot) on Jul 28, 2003 at 03:54 UTC | |
by Anonymous Monk on Jul 28, 2003 at 04:35 UTC | |
by sauoq (Abbot) on Jul 28, 2003 at 05:06 UTC | |
by sauoq (Abbot) on Jul 28, 2003 at 06:34 UTC | |
|
Re: mathematical equation
by halley (Prior) on Jul 28, 2003 at 14:06 UTC |