jeffa, here are my 2 eurocents on this one:

Return a string containing the results wrapped in HTML table tags: <TABLE> <TR> <TH> and <TD>

Make also sure that you use the other table elements described in the W3C Table Model such as the COLGROUP, COL, CAPTION, THEAD, TBODY and TFOOT elements (and their proper required attributes). Your users will be thankful to you when they will fire up large queries and/or try to parse the table afterward. The other advantage is to be able to provide the table as a stream and see it displayed as the informations come.

Allow user to specify attributes for each of the table tags, such as WIDTH, CLASS, ALIGNMENT etc. Allow user to format each <TH> and <TD> elements to allow for FONT tags. This would definately be a 'global' thing - set this value and all elements are effected

The FONT tag is deprecated (but not deprecated) since three years now. The easiest and smartest way to handle the diplaying style of your table is to use stylesheets. Most decent browser deals fairly well with them as long as you don't go down into the intricacies of the DOM. Providing a default overidable stylesheet might be a good thing.

Calculate totals (and possibly subtotals) on specified columns, the columns should be accessible by their names, maybe by their number in the list of columns - user's responsibility to make sure the rows would be numeric

Just to be sure, you will leave the calculations to the database and just create the result row in your table, won't you?

Now, to answer your questions, apart from DBIx::XML_RDB (which I discovered by your tutorial) I haven't yet found such module though I recall having coded several times not so long ago such functions (HTML tables from SQL queries, alternating colors, subtotal, etc...). I'm pretty sure that if this module would be available, I'll have more spare time to spend in the CB.

As for the name, I'll defintely go for DBIx::XHTML_Table, since HTML is dead (or should be, really). Again, most browsers won't see any difference, but the people who will to work seriously with the tables generated will thank you all the more (and you can parse XHTML with either HTML::Parser or XML::Parser).

Update: I haven't looked at it, but there's a module called DBIx::HTMLView which looks a lot like what you're trying to do.

<kbd>--
my $OeufMayo = new PerlMonger::Paris({http => 'paris.mongueurs.net'});</kbd>

In reply to Re: SQL query to HTML table by OeufMayo
in thread SQL query to HTML table by jeffa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.