I have a CGI page with a table which is populated by fetching the data from database, in a word its like a DATAGRID.
And just at the bottom right end of tha Grid I need a link like "First << 1 2 >> Last" or like" |< < > >| "on clicking which I can navigate to and fro the records. And I am intend to have "10" records per page.
While surfing I got a piece of code which I am going to paste in the code field. But problem is that it displays the paging link something like this "1 2 3 4 5 ..and so on". But I am not willing to have this paging format because the number of records increases the length of the link also goes on increasing. So can this code be modified to the format which I am intending to have?
#!C:\perl\bin\perl.exe -wT
use CGI;
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);
use strict;
use warnings;
use DBI;
my $query = new CGI;
my $bornum;
my $itemnum;
my $i;
my @overduedata;
my $pageNum =$query->param('pageNum');
print "Content-Type: text/html\n\n";
unless($pageNum) {
$pageNum=0;
}
my $offset=$query->param('offset');
unless($offset) {
$offset=10;
}
$i=0;
my $numOfRec = 100;
while ($i < $numOfRec){
$bornum = "bornum" . $i;
$itemnum = "itmnum" . $i;
push (@overduedata, { bornum => $bornum, itemnum => $itemnum });
$i = $i + 1;
}
print "<meta http-equiv=\"Content-Type\" content=\"text/html; charset=iso-8859-1\">";
print "\n<form>";
print "\nNo: of records per page : <input type=text name=offset>";
print "\n<input type=submit value=submit>";
print "\n</form>";
print "\n<br> No: of rec per page = " . $offset . " -- pageNum = " . $pageNum ;
print "<table border=1>";
my $startDisplay = ($pageNum) * $offset;
my $endDisplay = ($pageNum + 1) * $offset;
$i = $startDisplay;
while ($i < $endDisplay){
print "<tr><td>" . $i . "</td><td>" . $overduedata[$i]->{'bornum'} . "</td><td>" .
$overduedata[$i]->{'itemnum'} . "</td></tr>";
$i = $i + 1;
}
print "</table>";
my $numofPages = $numOfRec / $offset;
$i = 0;
print "<table border=1><tr>";
while ($i < $numofPages){
print "<td> <a href = ?pageNum=" . $i . "&offset=" . $offset . ">" .
$i . "</a></td>";
$i = $i + 1;
}
print "<tr></table>";
---------------------------------------------------------------------------------------