________________________________________ From: templates-boun...@template-toolkit.org [templates-boun...@template-toolkit.org] on behalf of Chad Wallace [cwall...@lodgingcompany.com] Sent: Thursday, September 27, 2012 3:02 PM To: templates@template-toolkit.org Subject: Re: [Templates] Multiple queries to populate drop down list boxes.
On Thu, 27 Sep 2012 17:10:39 +0000 Mark Haney <ma...@abemblem.com> wrote: > > my @rows_shift; > > while (my $row_shift = $sth->fetchrow_array() ) > > { > > push @rows_shift, $row_shift; > > } BTW, this is equivalent: my $rows_shift = $sth->fetchall_arrayref(); So, in other words I don't really need the while loop? That was used in the previous instance because of the fact that data is an array and not just a list. (In fact I have another page where the elements are identified in the script. I don't remember why I didn't do this one like that. And then instead of \@rows_shift, you pass $rows_shift to your $vars. Similarly for the factories one, you could use this: my $rows_factory = $sth->fetchall_arrayref({}); But you would also need to add aliases to your column names, so they are named "id" and "abbr", or change the template to use their actual column names. TIMTOWTDI, of course! > #The part where it gets passed to the HTML: > > > my $file = 'templates/shift_rpt.html'; > > my $vars = { > > 'cgi' =>CGI->new(), You probably don't want to make a new CGI object here. Try passing in the one that's already made ($cgi). I'm not entirely sure, but I think when CGI does its parsing, it's destructive about it, so a second object wouldn't necessarily get the same data. So far, I've not had a problem with creating a new CGI object there. And I really can't see why it would suddenly be a problem now, but only for one variable. For now, I think if it ain't broke, I won't try to fix it. One thing at a time. -- C. Chad Wallace, B.Sc. The Lodging Company http://www.lodgingcompany.com/ OpenPGP Public Key ID: 0x262208A0 _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates _______________________________________________ templates mailing list templates@template-toolkit.org http://mail.template-toolkit.org/mailman/listinfo/templates