I found this somewhere, I don't know the source. Helpful to build next, previous links also.
sub BuildNextPrevLinks { my ($query,$blankon,$total,$numdisplay,$position) = @_; my ($startno,$endno,$prevstring,$nextstring,$firststring,$laststri +ng); my ($lastpagenum,$laststart); return unless ($total || $blankon); $numdisplay=15 unless $numdisplay; # calculations need to be based on total found not our display tot +al if ($total > $numdisplay) { $startno = $position+1; $endno = $startno + ($numdisplay - 1); $endno = $total if ($endno > $total); } else { # when we have less than the number of rows passed in $startno = 1; $endno = $total; } if ($position>=$numdisplay) { my $newquerystring; my $prevstart = $position - $numdisplay; my $prevlink = &EditQueryString($query,'position',$prevstart); $prevstring="<a href=\"$prevlink\">Previous $numdisplay</a>"; my $firstlink = &EditQueryString($query,'position',0); $firststring="<a href=\"$firstlink\">First $numdisplay</a>"; } else { $prevstring="Previous $numdisplay" if ($blankon); $firststring="First $numdisplay" if ($blankon); } if ($endno<$total){ my $nextstart = $position + $numdisplay; my $how_many_left = $total - $nextstart; if ($how_many_left > $numdisplay) { $how_many_left = $numdisplay; } my $nextlink = &EditQueryString($query,'position',$nextstart); $nextstring="<a href=\"$nextlink\">Next $how_many_left"; $lastpagenum = ($total % $numdisplay); $laststart = $total - $lastpagenum; my $lastlink = &EditQueryString($query,'position',$laststart); $laststring="<a href=\"$lastlink\">Last $lastpagenum</a>"; # $laststring="<a href=\"$lastlink\">Last $lastpagenum</a>"; } else { $nextstring="Next $numdisplay" if ($blankon); $laststring="Last $numdisplay" if ($blankon); } return ($firststring,$prevstring,$nextstring,$laststring,$startno, +$endno); }

In reply to Re: Number of listings per page by artist
in thread Number of listings per page by coldfingertips

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.