View Single Post
  #1 (permalink)  
Old 03-10-2008, 02:30 AM
hhheng hhheng is offline
Newbie
 
Join Date: Nov 2007
Posts: 4
Rep Power: 0
hhheng is on a distinguished road
Default Newbie questions: how to show a listing in pages

I'm showing a directory listing in one page now, but I want to show it in pages.

Currently I'm working like this:

Quote:
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:

Quote:
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:

Quote:
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?

Last edited by hhheng; 03-10-2008 at 02:57 AM.
Reply With Quote

Sponsored Links