Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Just wanted to post my code as an update on how I did this in case anyone is ever interested in the same thing: The trick was in my SQL statement...
my $sth = $dbh->prepare( " select t.id,t.user,t.email,t.status,t.date,t.req_date, ( SELECT GROUP_CONCAT( (case when status = 'Approved' then user + end) separator ', ') FROM requests s WHERE s.date = t.date) AS approved FROM requests t WHERE status = 'Pending' AND req_email = '$email' AND date >= '$date' ORDER BY employee,date " ); $sth->execute(); my $reqs; push @{$reqs}, $_ while $_ = $sth->fetchrow_hashref(); my $template = HTML::Template->new( filename => 'approve.html' + ); $template->param( REQS => $reqs, ); print $template->output();
And here's my template code:
<TMPL_IF REQS> <form> <table class=approve> <tr> <th class=approve>Approve</th> <th class=approve>Decline</th> <th class=approve>Date</th> <th class=approve>Employee</th> <th class=approve>Status</th> <th class=approve>Request Date</th> </tr> <TMPL_LOOP NAME=REQS> <tr class=approve> <td class=approve><input type=radio name=apid<TMPL +_VAR NAME=ID> value=Approved></td> <td class=approve><input type=radio name=apid<TMPL +_VAR NAME=ID> value=Declined></td> <td class=approve> <TMPL_IF NAME=APPROVED> <span class="hotspot" onmouseover="tooltip +.show('<strong>Approved Vacation Requests</strong><br /><TMPL_VAR NAM +E=APPROVED>');" onmouseout="tooltip.hide();"> </TMPL_IF> <TMPL_VAR NAME=DATE> <TMPL_IF NAME=APPROVED> </span> <script type="text/javascript" language="j +avascript" src="js/script.js"></script> </TMPL_IF> </td> <td class=approve><TMPL_VAR NAME=USER></td> <td class=approve><TMPL_VAR NAME=STATUS></td> <td class=approve><TMPL_VAR NAME=REQ_DATE></td> <input type=hidden value=<TMPL_VAR EMAIL> name=emp +_email<TMPL_VAR NAME=ID>> <input type=hidden value=<TMPL_VAR EMPLOYEE> name= +emp_name<TMPL_VAR NAME=ID>> <input type=hidden value=<TMPL_VAR DATE> name=date +<TMPL_VAR NAME=ID>> </tr> </TMPL_LOOP> <tr class=approve> <th class=approve colspan=6> <input type=submit value="Approve / Decline"> <input type=hidden value=process name=state> </th> </tr> </table> </form> <TMPL_ELSE> <br /><b>There are no pending requests!</b><br /> </TMPL_IF>

In reply to Re^3: HTML::Template if key of hash matches value of hash. by walkingthecow
in thread HTML::Template if key of hash matches value of hash. by walkingthecow

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!
  • 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, 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, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            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.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others pondering the Monastery: (6)
    As of 2014-12-20 21:53 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (99 votes), past polls