my $sql_statement = "SELECT * from foo where bar = \"$baz\" "; my $sth = $dbh->prepare($sql_statement); $sth->execute() or die "Can't execute SQL statement : $dbh->errstr"; $sth->bind_columns(undef, \$FOO,\$BAR,\$BAZ,\$ONE,\$FOR,\$EACH,\$COLUMN); my $row; while ($row = $sth->fetchrow_arrayref) { my @fields = ( $row->[9],$row->[0],$row->[1],$row->[2],$row->[3], $row->[4],$row->[5],$row->[6],$row->[7],$row->[8] ); #i fooled with the order to make it print in the order i wanted &showrow(@fields); } $sth->finish; # this is where you tailor your output however you want sub showrow { print "\n"; # start your table row foreach $value (@_) { print $value; # this is where you do table data } print "\n"; # stop your table row }