The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

HTML::Table::FromDatabase - subclass of HTML::Table to generate tables easily from a database query

SYNOPSIS

 my $sth = $dbh->prepare('select * from my_table')
    or die "Failed to prepare query - " . $dbh->errstr;
 $sth->execute() or die "Failed to execute query - " . $dbh->errstr;

 my $table = HTML::Table::FromDatabase->new( -sth => $sth );
 $table->print;

DESCRIPTION

Subclasses HTML::Table, providing a quick and easy way to produce HTML tables from the result of a database query.

I often find myself writing scripts which fetch data from a database and present it in a HTML table; often resulting in pointlessly repeated code to take the results and turn them into a table.

HTML::Table itself helps here, but this module makes it even simpler.

Row headings are taken from the field names returned by the query.

All options you pass to the constructor will be passed through to HTML::Table, so you can use all the usual HTML::Table features.

INTERFACE

new

Constructor method - consult HTML::Table's documentation, the only difference here is the addition of the required -sth parameter which should be a DBI statement handle.

AUTHOR

David Precious, <davidp@preshweb.co.uk>

COPYRIGHT AND LICENSE

Copyright (C) 2008 by David Precious

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.7 or, at your option, any later version of Perl 5 you may have available.