Hi all, This will probably go down as the silliest question of the day, but it is very early and I have been up all night....

Anyway, I am trying to use HTML::Pager after a search in MySQL. So, my question is how do I get the search results into Pager?

Thanks for reading!
Jim

#!/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;

In reply to HTML Pager by JimJx

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.