sub BuildNextPrevLinks { my ($query,$blankon,$total,$numdisplay,$position) = @_; my ($startno,$endno,$prevstring,$nextstring,$firststring,$laststring); my ($lastpagenum,$laststart); return unless ($total || $blankon); $numdisplay=15 unless $numdisplay; # calculations need to be based on total found not our display total 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="Previous $numdisplay"; my $firstlink = &EditQueryString($query,'position',0); $firststring="First $numdisplay"; } 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="Next $how_many_left"; $lastpagenum = ($total % $numdisplay); $laststart = $total - $lastpagenum; my $lastlink = &EditQueryString($query,'position',$laststart); $laststring="Last $lastpagenum"; # $laststring="Last $lastpagenum"; } else { $nextstring="Next $numdisplay" if ($blankon); $laststring="Last $numdisplay" if ($blankon); } return ($firststring,$prevstring,$nextstring,$laststring,$startno,$endno); }