>    Hi all. I'm considering developing a small set of routines to
> format the results of database queries done through DBI in HTML.

If you want a simple but effective search/insert/update/delete engine,
take a look at www.wdbi.net.

Otherwise, if all you want to do is format the output of a query here's
the minimalist solution using CGI.pm:

use CGI qw(:standard);
use DBI;

my $dbh = DBI->connect('dbi:$driver:$dsn', $user, $passwd,
{RaiseError=>1})
        or die $DBI::errstr;

my $sth = $dbh->prepare($sql_statement);
$sth->execute();

print header, start_html;

# Schwartzstein-Bunce Transform
print table({-border=>undef},
                caption('TableName'),
                Tr(map(th($_), @{$sth->{NAME}})),
                map(Tr(td($_)), @{$sth->fetchall_arrayref()}),
        );

print end_html;

$sth->finish;
$dbh->disconnect if $dbh;

1;

__END__

As you can see it doesn't warrant a separate module but it does deserve
a place in the Cookbook.

Reply via email to