Re: multiple fields from SQL query --Update

Mark Haney <markh-rOuQeLG7NUhWk0Htik3J/[email protected]> Thu, 31 May 2012 10:42:39 -0400
Newsgroups gmane.comp.lang.perl.modules.template-toolkit
Message-ID <[email protected]>
On 05/24/2012 02:53 PM, Theunis De Klerk wrote:

>
> As an example, how does this work for you :
>
> my @rows_factory;
> while ( my @factory_data = $sth->fetchrow_array() )
> {
> push @rows_factory, {'id' => $factory_data[0], 'abbr' => $factory_data[1]};
> }
>
> I normally do that when I want to do this in the template :
>
> <select name="factory">
> [% FOREACH factory IN factories %]
> <option value="[% factory.id %]" size="20">[% factory.abbr %]</option>
> [% END %]
> </select>
>

I'm an idiot.  It works now.  I had some issues with the FOREACH line. 
My 'factories' data was actually under the array @factory.  Since I'm 
still new to the toolkit, I got my variable names all screwed up.  It is 
a good reminder to not have duplicate or similar variable names. 
Especially for me and my ADHD.

Thanks again.

-- 

Mark Haney
Software Developer/Consultant
AB Emblem
markh-rOuQeLG7NUhWk0Htik3J/[email protected]
Linux marius.homelinux 3.3.7-1.fc16.x86_64 GNU/Linux