On Thu, Apr 11, 2002 at 05:04:46PM +0200, O de Zwart wrote:
Let's invert the example in order to answer the question:
> with this in my tmpl:
> ================================================================
><tmpl_var name="<tmpl_var name="columnName">">
This construct is invalid. template variable names cannot be themselves
other variable names. HTML::Template supports a single level of evaluation.
The solution:
Change the template to use a list of lists of hashes and change the
code to generate said list of lists of hashes.
> with this in my tmpl:
> ================================================================
> <tmpl_loop name="columns">
> [snip]
> </tmpl_loop>
> </tr>
> <tmpl_loop name="data">
> <tr>
> < tmpl_loop name="row">
> <td bgcolor="#dee3e7"><font color="#474791" size="2"
>face="Arial,Helvetica,Geneva,Swiss,SunSans-Regular">
<tmpl_var name="row_value">
> </font></td>
>
> </tmpl_loop>
> </tr>
> </tmpl_loop>
=pod
delete this whole thing. You don't need it.
Note that you will need it if you are using other information aside from the
fieldnames.
> my $sth = $dbh->prepare( "describe $table" );
> $sth->execute;
> my $i = 0;
> while ( my @row = $sth->fetchrow_array() ) {
> my %column = ( columnName => $row[0]);
> push @columns, \%column;
> }
=cut
>
> my $sql = "SELECT * FROM table";
> my $sth = $dbh->prepare($sql);
> my $data = [];
> $sth->execute;
#grab the column names from the query results
my @column = map { { columnName => $_ } } @{$sth->{NAME}};
#create a list of lists of hashes
while (my @row = $sth->fetchrow_array()) {
push @$data, [ map { { row_value => $_ } } @row ]
}
> $sth->finish;
>
> $dbh->disconnect;
--Gyepi Sam
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]