Which of the many HTML modules or templating modules are you using at present and where are you having trouble with whatever you are using?
If you are not using any such tool at present perhaps you should at least mention the copntext for the question. It's pretty unusual for HTML tables to stand on their own and the rest of the task will influence what is most appropriate for your task.
use strict;
use warnings;
use DBI;
use HTML::TableTiler;
my @matrix;
my $dbh = DBI->connect( "DBI:mysql:project") or die "Can't connect to
+Oracle database: $DBI::errstr\n";
my $sth = $dbh->prepare("select * FROM modules");
$sth->execute || $sth->errstr();
while (my @row = $sth->fetchrow_array) {
push (@matrix, [@row]);
}
$dbh->disconnect;
my $tt = HTML::TableTiler->new();
print $tt->tile_table(\@matrix);
You don't check the result of $dbh->fetchrow_array.
Your loop can be replaced with $sth->fetchall_arrayref.
You can also condense the code further using $dbh->selectall_arrayref.
use strict;
use warnings;
use DBI ();
use HTML::TableTiler ();
my $dbh = DBI->connect("DBI:mysql:project")
or die "Can't connect to Oracle database: $DBI::errstr\n";
my $matrix = $dbh->selectall_arrayref("SELECT * FROM modules");
die "Unable to fetch query results: $DBI::errstr\n" if $dbh->err;
my $tt = HTML::TableTiler->new();
print $tt->tile_table($matrix);
I would probably use map and join, but you could just as easily use foreach and concatenation. Either way you can use HTML::Entities for escaping. Which part are you having trouble with? Can you show us what you've tried so far? We could probably give you better, more specific help if you ask a more specific question.
Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. Why, I've got so much sanity it's driving me crazy.