Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Syntactic Confectionery Delight
 
PerlMonks  

Re^2: Build Table with 'n' rows and 'm' columns

by ikegami (Patriarch)
on Nov 02, 2006 at 04:33 UTC ( [id://581859]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Re: Build Table with 'n' rows and 'm' columns
in thread Build Table with 'n' rows and 'm' columns

There room for a some small improvements.
  • You don't check the result of $dbh->prepare.
  • 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);

Update: I was obviously tired! Fixed the problems identified in replies.

Replies are listed 'Best First'.
Re^3: Build Table with 'n' rows and 'm' columns
by mreece (Friar) on Nov 02, 2006 at 10:07 UTC
    there is still room for some small improvement!
    Global symbol "$sth" requires explicit package name
    ;-)
      And more. Personally, I prefer using SELECT over SELET ;-)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://581859]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.