From: Philip Tellis <[EMAIL PROTECTED]>
>
>I do it by pushing the selected evaluation right to the SQL:
>
>SELECT foo, bar, baz, IF(bar='myval', 'selected', '') AS selected FROM 
>...
>
>and then just throw it into an arrayref.

That's the nifty SQL I mentioned seeing before. It was posted by Puneet.[1]

============================
SELECT val,
         text,
         (if then else to return "selected" or "") AS selected
 FROM table
 WHERE whatever...
 
 then in my template...
 
 <tmpl_loop occupations>
    <option value="<tmpl_var val>" <tmpl_var selected>>
      <tmpl_var text>
    </option>
 </tmpl_loop>
=============================

But, the other nifty part was posted by Jason. He suggested using DBI's 
fetchall_arrayref to directly populate the template without putting the values 
in your own hash:

=============================
 $sth->execute();
 $template->param( "OCCUPATION_LOOP" => $sth->fetchall_arrayref( {} ) );
=============================

[1] http://sourceforge.net/mailarchive/message.php?msg_id=8192715
[2] http://sourceforge.net/mailarchive/message.php?msg_id=8192723

Mark


-------------------------------------------------------
The SF.Net email is sponsored by: Beat the post-holiday blues
Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek.
It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt
_______________________________________________
Html-template-users mailing list
Html-template-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to