Hi Dermot,

> my $file = "test.atm";
> my $vars = {
>                 data => @data,
>                };
> $tt->process($file,$vars)
>         || die $tt->error;

I think the creation of your hash above should read:

my $vars = {
   data => \@data,
   };

since you must pass your array of data as a reference. Then, to make
your template code work, each element in your data array must be a
hash reference, e.g.

my (@data) = (
   {'id'=>1, 'name'=>'abc'},
   {'id'=>2, 'name'=>'def'},
   # ...
   );

> [% FOREACH item = data %]
> [% FOREACH i = item %]
> <tr>
>  <td>item1=[% i %]</td><td>item2=[% i.id 
> %]</td><td>items=[%i.name %]</td>
> </tr>
> [% END %]
> [% END %]
> </table>

>From the other mail:
Be also sure that you are using the DBI functions correctly:

> sub getusers
> {
>   my @results;
>   while (my ($id, $name, $surname) = $sth->fetchall_arrayref))
>  {
>  push @results, {id=>$id, name=>$name, surname=>$surname}
>  ...
>  }
>   return \@results;
> }

In the code above, you must use $sth->fetchrow_array().
fetchall_arrayref() returns all records as an array reference of
array references and you would use it somewhat like this:

my ($data) = $sth->fetchall_arrayref();

Best regards,
Axel


_______________________________________________
templates mailing list
[EMAIL PROTECTED]
http://www.template-toolkit.org/mailman/listinfo/templates

Reply via email to