in reply to Re: multiple perl-mysql queries...
in thread multiple perl-mysql queries...

Thanks for your update, jeffa :)

I experimented with your code but I find it rather difficult to understand especially with the double map.

I would like to print out the names of the columns, just like your code does (names of columns, followed by columns' values). How can I do that with my code using fetcharray_row()?

Replies are listed 'Best First'.
3Re: multiple perl-mysql queries...
by jeffa (Bishop) on Dec 04, 2003 at 18:30 UTC
    Using your original code, it would look something like this:
    my $sth = $dbh->prepare("select * from foo"); $sth->execute; print qq~<table>\n~; print qq~<tr>\n~; foreach (@{$sth->{NAME}}) { print qq~<th>$_</th>\n~; } print qq~</tr>\n~; while (my @ary = $sth->fetchrow_array) { print qq~<tr valign="top">\n~; foreach (@ary) { $_ = defined($_) ? $_ : '&nbsp;'; print qq~<td>$_</td>\n~; } print qq~</tr>\n~; } print qq~</table>\n~;
    But if you haven't tried DBIx::XHTML_Table yet, please do.

    jeffa

    L-LL-L--L-LL-L--L-LL-L--
    -R--R-RR-R--R-RR-R--R-RR
    B--B--B--B--B--B--B--B--
    H---H---H---H---H---H---
    (the triplet paradiddle with high-hat)