You are correct... try fetchrow_arrayref and you should get what you are expecting

On 05/24/2012 02:14 PM, Mark Haney wrote:
On 05/24/2012 10:52 AM, Mark Haney wrote:
I've got a query in my perl code to pull 2 fields from a database
(abbreviation, factory_id), one of which is used to populate a dropdown
box (abbreviation). However, I will need to pass /both/ fields to the
CGI script that I'm calling from the form that has the dropdown box. How
do I do that? Here's what I have so far:

shift_rpt.pl:

my $sql = qq/SELECT factory_id, abbreviation from factory/;
my $sth = $dbh->prepare($sql);
$sth->execute();


my $row_factory;
my @rows_factory;
while ($row_factory = $sth->fetchrow_array)
{
push @rows_factory, $row_factory; # This moves each row into the array
@rows
}
$sth->finish();


I've had a couple of good suggestions on how to handle this, but I'm obviously missing something. In the WHILE loop above, I'm not getting both fields from the query. I.e. I'm getting the last element of the query (abbrev) pushed into the array @rows_factory but not the factory_id. I'm guessing it's due to the fact that I'm fetching the row into a scalar ($row_factory) and not an array. Correct?

I just can't seem to get the logic of this straight in my head. Maybe I'm over-complicating things because of the toolkit. Seems to me like the toolkit is sitting there complicating my thought process when it really shouldn't.





--
Todd Freeman  Ext 6103                   .^.    Don't fear the penguins!
Programming Department                   /V\
Andrews University                      // \\    http://www.linux.org/
http://www.andrews.edu/~freeman/       /(   )\   http://www.debian.org/
                                        ^^ ^^


_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to