Hi Monks!

I am trying to process a MySQL query and send the results to the browser using Template Toolkit. It is my understanding that TT2 will only handle lists and hashes. I have opted to use a hash.

My query requires that I pass several records of data to the browser. I am trying to loop fetchrow_array() to to process each record to see if there is a match (my query includes a filtered search). If there is a match, I need to retrieve several columns of data from that record. So I have multiple pieces of data and multiple records to deal with.

Normally, I would format and print these results to the browser as part of the query. However, TT2 requires me to send this information to the browser via a template (as I'm sure you know). So it seems like I have to build a hash. I can write code to do this using all the scalar data, but I'm wondering if there is an easier (preferred) way to process this query. Seems like a lot of work (especially when TT2 makes so many other things so easy to do). Did I mention I have little experience using TT2?

What is the best way to do this?

Thanks for your time.


In reply to Best way to send records to the browser? by Perobl

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.