HTML::Table::FromDatabase released

I’ve just released a new Perl module to CPAN, HTML::Table::FromDatabase. It’ll hit CPAN mirrors soon.

It subclasses HTML::Table, and its purpose is to simplify a fairly common task, of taking data from a database query and displaying it in a HTML table.

I quite often find myself writing reporting-type scripts which do a database query, then want to present that information in a table. Generating the table yourself isn’t hard, but it’s annoying and clutters your code with HTML tags. I started using HTML::Table to make this a lot easier, but you still need some code to take the data and set up the table with it.

HTML::Table::FromDatabase makes it as easy as passing the executed statement handle to the constructor, which will give you a back an HTML::Table object ready to print:

# Standard DBI stuff (yes, in the real world there'd be error-checking)
my $dbh = DBI->connect('dbi:mysql:test');
my $sth = $dbh->prepare('select * from mytable');
$sth->execute();

my $table = HTML::Table::FromDatabase->new( -sth => $sth, -border => 1 );

When creating a HTML::Table::FromDatabase object, all the standard HTML::Table options can still be used, there’s just one extra mandatory option, -sth, which must be the statement handle to use.

Hope it’s of use to someone :)

0 Responses to “HTML::Table::FromDatabase released”


  1. No Comments

Leave a Reply

In the CAPTCHA box above, you must type both words you see. If they're too hard to read, click the "Get a new challenge" button (the top one of the three to the immediate right of the text entry box). Sorry for making you jump through hoops, but I've been suffering from way too much spam lately.

Subscribe without commenting





get some tasty email addresses here