#!/usr/bin/perl -w use CGI::Carp qw/fatalsToBrowser warningsToBrowser/; $|++; use strict; use warnings; use diagnostics; use DBI; use CGI; use HTML::Pager; my $row; # get CGI query object my $query = CGI->new(); my $dbname = "DBI:mysql:farthing_valleyweb"; my $dbusername = "farthing_farthin"; my $dbpassword = "ginajim"; my $dbh = DBI->connect($dbname, $dbusername, $dbpassword, { RaiseError => 1, PrintError => 0 }); # The sql for selecting out of the DB my $sql = 'select * from valley where category like "Real Estate"'; # Prepare the SQL and then execute it my $db_query = $dbh->prepare($sql); $db_query->execute(); # store each record into @results while (my @results = $db_query->fetchrow_array()) { push(@results, $row); } # create a callback subroutine to generate the data to be paged my $get_data_sub = sub { my ($offset, $rows) = @_; my @return_array; for (my $x = 0; $x < $rows; $x++) { push(@return_array, [ $row ]); } return \@return_array; } ; my $pager = HTML::Pager->new( query => $query, get_data_callback => $get_data_sub, rows => 100, page_size => 3, ); # make it go - send the results to the browser. print $pager->output;