CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [terrykhatri531] Need help to improve pagination: Edit Log



Zhris
Enthusiast

Aug 7, 2014, 9:46 AM


Views: 6549
Re: [terrykhatri531] Need help to improve pagination

I must keep insisting that you use Data::Page!


Code
$entries_per_page = 10 unless ($entries_per_page =~ m/^[1-9]\d*$/); 

my $page = Data::Page->new;

$page->total_entries($total_entries);
$page->entries_per_page($entries_per_page);
$page->current_page($current_page);

# pageset
my $first_page = $page->first_page; # should always be 1.
my $last_page = $page->last_page;

# resultset
my $offset = $page->first - 1; # will be 0 if on first page.
my $limit = $page->entries_on_this_page;


Chris


(This post was edited by Zhris on Aug 7, 2014, 9:53 AM)


Edit Log:
Post edited by Zhris (Enthusiast) on Aug 7, 2014, 9:47 AM
Post edited by Zhris (Enthusiast) on Aug 7, 2014, 9:53 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives