Thanx Rafiq,
I tried the 1st 2 methods 
-------
1)      return {id=>$id, name=>$name, surname=>$surname};
        and then in pass the template:
        process ($path, {data=>getusers})
2)
        @data =getusers;
        just process($path, {data=>{id=>$data[0], name=>$data[1],
surname[2]}});
--------
and I got this:
item1=HASH(0x8531e4c) item2= item3= 
item1=HASH(0x8531df8) item2= item3= 
item1=HASH(0x8531ee8) item2= item3=

Bearing in mind that item1 is the 2nd iteration through @data:

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

So it looks like that gives me an array of hashes??but still nothing in 
i.id & i.name. I also tried the other method changing &getusers but 
DBI execute statement was failing:
error 19 recorded: fetch() without execute() 
Believe me there is an execute statement so I am not sure what was 
happening.

Is there no way to do something like:
[% FOREACH item = data %]
[% FOREACH i = item[1,2,3]%]
<tr>
 <td>item1=[% i.1 %]</td><td>item2=[% i.2 %]</td><td>item3=[% i.3 
%]</td>
....
to access the elements within the array?
Dp.




On 15 Oct 2002 at 14:57, Rafiq Ismail wrote:

> Second glance:
> 
> On Tue, 15 Oct 2002, Dermot Paikkos wrote:
> >
> > (my @data) = &getusers();
> > ....
> > sub getusers {
> > ......
> >   while (my ($id,$name,$surname) = $sth->fetchall_arrayref) {
> >         return $id,$name,$surname;
> >         }
> > }
> 
> The following should do the trick, assuming that @$data is an array of
> lots of hrefs of id, name, surname.. :
> 
> sub getusers
> {
>   my @results;
>   while (my ($id, $name, $surname) = $sth->fetchall_arrayref))
>  {
>  push @results, {id=>$id, name=>$name, surname=>$surname}
>  ...
>  }
>   return \@results;
> }
> 
> $t->process ($path, {data=>getusers});



~~
Dermot Paikkos * [EMAIL PROTECTED]
Network Administrator @ Science Photo Library
Phone: 0207 432 1100 * Fax: 0207 286 8668


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

Reply via email to