Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: How to create a table with rows and columns using HTML::Template loops?

by porta (Sexton)
on Jun 24, 2009 at 03:30 UTC ( [id://774237]=note: print w/replies, xml ) Need Help??


in reply to How to create a table with rows and columns using HTML::Template loops?

##UPDATE I just re read your message and noticed this wont work for you. Sorry. This have been doing the trick for me. For the html template:
<table> <thead> <tr> <!-- tmpl_loop name="fields" --> <th><!-- tmpl_var name="field" --></th> <!-- /tmpl_loop --> </tr> </thead> <tbody> <!-- tmpl_loop name="data" --> <tr> <!-- tmpl_loop name="cols" --> <td><!-- tmpl_var name="value" --></td> <!-- /tmpl_loop --> </tr> <!-- /tmpl_loop --> </tbody> </table>
And, the perl part:
my @fields = qw(your columns names here); $object->get_all(%params); while (my $obj = $object->get_next){ my @row = map {{value => $obj->$_}} @fields; push @data, {cols => \@row}; } $template->param(fields => \@fields); $template->param(data => \@data);
Hope this helps.

Replies are listed 'Best First'.
Re^2: How to create a table with rows and columns using HTML::Template loops?
by BlenderHead (Novice) on Jun 24, 2009 at 04:14 UTC

    If then anyone can help, the question still holds!

    Thanks for trying!

    BH

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://774237]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2026-05-14 01:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.