RE: [htmltmpl] Adding to a row in a loop
Brought to you by:
samtregar
From: Kenny S. <ke...@jo...> - 2002-08-06 00:31:29
|
Hi Todd, I'm not exactly sure what you are trying to do that you aren't actually accomplishing with the code you provided, but in any case, I would suggest something more like this: -------- snip ---------- my $template = HTML::Template->new( filename => 'showclient.html' ) ; my $rc = $sth->execute() ; my ( $data , $rows ); while( $data = $sth->fetchrow_hashref() ) { push( @{$rows} , $data ) ; } $template->param( { results => $rows } ) ; print $template->output() ; -------- end ------------ It's a good idea to never set $_ yourself... you should always use your own variable. Kenny -----Original Message----- From: htm...@li... [mailto:htm...@li...]On Behalf Of Todd Schacherl Sent: Monday, August 05, 2002 4:53 PM To: htm...@li... Subject: [htmltmpl] Adding to a row in a loop Hi Folks, I think this might be a basic PERL question but it does involve H::T. :o) But maybe somebody here can help me anyway...I'm using the loop ability with H::T to print out rows where each row is a form. I want to add a tag field for each row with the same data for that field in each row. How do I push that into the $rows that I pass to H::T? my $rc = $sth->execute(); my $tmpl_obj; # prepare a data structure for HTML::Template my $rows; push @{$rows}, $_ while $_ = $sth->fetchrow_hashref(); # instantiate the template and substitute the values $tmpl_obj = $self->load_tmpl('showclient.html'); $tmpl_obj->param(results => $rows); Thanks in advance, Todd Schacherl ht...@zo... |