On Apr 18, Hawkes, Mick I said:
sub mainmenu { my $self = shift; my $dbh = $self->param('mydbh');
# Get the CGI query object so that you can use the CGI.pm modules. my $q = $self->query();
# Setup the template to use for the output. my $template = $self->load_tmpl('test2.tmpl.htm');
# call param to fill in the loop with the loop data by reference. $template->param(db_loop => \GetOfficers());
Does the db_loop thing take an array reference, or a function reference? I'm assuming it's supposed to take an array reference. You should probably just have GetOfficers() RETURN an array reference.
# Output the template... $template->output; }
And this is the sub Getofficers:
sub GetOfficers { my $self = shift;
Ah. You didn't GIVE any arguments to the GetOfficers() function. Perhaps you want to do:
$template->param(db_loop => GetOfficers($self));
in your mainmenu() function.
# my $self = @_; my $dbh = $self->param('mydbh'); # Get the CGI query object so that you can use the CGI.pm modules. my $q = $self->query(); my $sqlstr = '';
$sqlstr = <<SQLStmt; SELECT Name FROM qryOfficer;
SQLStmt #SELECT Family FROM tblOfficer;
# Get the database connection then Prepare and Execute the SQL Statement my $sth = $dbh->prepare($sqlstr); $sth->execute() || die "Could not execute SQL Statement!!\n$sqlstr";
# Setup the template to use for the output. my $template = $self->load_tmpl('test2.tmpl.htm'); my @Officer; # the loop data will be put in here for the html template.
# Now get the table rows and send the list off to the HTML form..... while (my $row = $sth->fetchrow_hashref) { #set up the data in an array to give to the HTML template.... my %line = ( HTML_ProjectName => $row->{Name}, ); # put this row into the loop by reference push(@Officer, \%line);
} return @Officer
Instead, say
return [EMAIL PROTECTED];
}
-- Jeff "japhy" Pinyan % How can we ever be the sold short or RPI Acacia Brother #734 % the cheated, we who for every service http://japhy.perlmonk.org/ % have long ago been overpaid? http://www.perlmonks.org/ % -- Meister Eckhart
-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>