I'm showing a directory listing in one page now, but I want to show it in pages.
Currently I'm working like this:
gtsee.com/cgi-bin/nph-dirsub.pl?invoice=invoices/merchant_invoice_999999
and the script for showing the listings are:
my $sql=SELECT id, name, url FROM free_dirs;
my ( $id, $name, $url) = @{$db_row}{qw/id name url};
print " " $id " " $name " " $url;
Now I want to show the listings in pages since there are thousands of listings in the database. So it shall like this:
gtsee.com/cgi-bin/nph-dirsub.pl?invoice=invoices/merchant_invoice_999999?page=x
Among this x=1, 2, 3, 4, 5, 6, etc.
And I tried this to display in several pages but not working:
my $max_listings = 200;
#$tmp is the total listings in the database
my $total_pages = $tmp/$max_listings;
my $page = $query->param('page');
if($page = "") $page = 1;
my $start = ($page - 1) * $max_listings;
my $sql=SELECT id, name, url FROM free_dirs LIMIT $start, $max_listings;
Can anybody help me for this issue?