Incase you still need help with this, here is some paging code I came up with that works off a total count of results how you get that is up to you... This code works with the bootstrap 3 pagination if you want different button styling you would have to figure that out. Also it displays 5 buttons at a time and styles the active page differently. Starts at page "0"
my $result_count = (however you want to get a total result count); if (!$page) {$page = '0'} my $offset = ($page * $max_page_results ); my $high_offset = ($offset + $max_page_results); my $total_pages = (ceil($result_count / $max_page_results) - '1'); my $next_page = ($page + '1'); my $previous_page = ($page - '1'); my $starting_page = ($page - '2'); #Setting limits to 0 and high page count if ($high_offset > $result_count) {$high_offset = $result_count;} if ($page == '0' ) {$previous_page = '0';} if ($next_page >= $total_pages) { $next_page = $total_pages; } #Displays 5 Page buttons at a time my @page_arr; my $ending_page = ($page + '2'); if ($starting_page < '0') {$starting_page = '0'; } if ($ending_page < '4') {$ending_page = ('4' - $starting_page);} if ($ending_page > $total_pages){$ending_page = $total_pages;} for my $i($starting_page..$ending_page){ push @page_arr, $i ;} #Results Display print '<div id="device-browse-all-display">'; print qq{ <div class="row"> <div class="col-sm-3"> <nav> <ul class="pagination"> <li> <a href="$ENV{'SCRIPT_NAME'}?page=$previous_page" ari +a-label="Previous"> <span aria-hidden="true">&laquo;</span> </a> < +/li>}; foreach my $page_link(@page_arr) { if ($page_link == $page) { print qq{<li class="active"><a href +="$ENV{SCRIPT_NAME}?page=$page_link">$page_link <span class="sr-only" +>(current)</span></a></li>}; } else { print qq{ <li><a href="$ENV{SCRIPT_NAME}?page=$p +age_link">$page_link </a> </li>}; } } print qq{<li> <a href="$ENV{SCRIPT_NAME}?page=$next_page" aria-lab +el="Next"> <span aria-hidden="true">&raquo;</span> </a> </li>};

In reply to Re: Perl Database Paging by howdoyouperl
in thread Perl Database Paging by ironside

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.