On Wed, Apr 10, 2002 at 10:48:03AM -0500, Kenny Pyatt wrote:
> Hello,
> 
> I am looking for a more attractive way to catch data from a query and 
> assign it to params in the template.
> 
> This is what I am doing.  Is there a "better" way?  Perhaps a dynamic 
> method that I could use.
> 
> # the query goes here
> my ($one, $two, $three) = $sth->fetchrow_array;
> 
> $template->param('one', $one);
> $template->param('two', $two);
> $template->param('three', $three);

while (my $h = $sth->fetchrow_hashref()){
      while(my ($k,$v) = each %$h){
               $template->params($k,$v);
      }
}

alternately, you could use

             my $a = $sth->fetchall_arrayref(); #fetchall_arrayref may have a 
different name
             $template->params(loopvar => $a);
             
and use <tmpl_loop> constructs.

HTH

-Gyepi Sam 


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to