Hi Dermot, On 10/08/10 4:49, Dermot wrote: snip > Hi, > > Not sure why you had to send this twice. Oops, sorry about it, to everybody. The first email (my time shows 8pm ++) was sent but it didn't turn up in my email client (on this mailing list, beginners@perl.org) and my hosting's webmail interface. After waited for 2 hours, then I sent again the second email (10 pm ++) and both turn up. I'm not sure why is it so.
snip > Line noise? What is it you want to cut out? > > You are iterating over the values of your hash. You don't need to > specify values here, you could omit the values and, according to the > TT man page[1] do: > > [% FOREACH kars %] > <li>[% reg_no %]....</li> > [% END %] > I've tried this and it doesn't work. But I think I'm quite satisfy with the current way of writing it as it kind of explain the hash relationship. e.g. [% PROCESS header %] Form <strong>List</strong> <p> <ul> [% FOREACH kar IN kars.values %] <li>[% kar.reg_no %], [% kar.brand %], [% kar.cc %]</li> [% END %] </ul> </p> [% PROCESS footer %] snip > I think you might be getting a bit confused here. TT requires > references for it's parameters variable, so yes array, hash references > (or any reference that returns a list) but that is different from how > you retrieve data from the DBI. You turned that data into a hash of > hash references when you did this: > You're absolutely correct about I'm confused. I can't differentiate what's array & array references, hash & hash references. And I thought all array are list. At one point when I try to pass multiple row of array (query from DBI using $sth->fetchrow_array) from perl to TT, it some how does not work. Until I stumble on this working codes from Perl Mongers and turn it into hash, then only it works. I was hoping someone over here can show some codes on how to use $sth->fetchrow_arrayref to pass arrays (or array references?) to TT. snip > If you want to use the DBI directly within TT then you should look at > using the TT DBI plugin[2]. you may get more help on TT matter from > the TT list[3]. > Not going to use DBI within TT as my intention for TT is to solely deal with design issue and keep the codes within CGI. Hopefully this will isolate problems (if any) and ease my learning picking up web programming. :) > Good luck, > Dp. > > > [1] http://template-toolkit.org/docs/manual/Directives.html#section_FOREACH > [2] http://search.cpan.org/~rehsack/Template-DBI-2.65/lib/Template/DBI.pod > [3] http://mail.template-toolkit.org/mailman/listinfo/templates > I'll definitely check out the TT's mailing list. Thanks for the explanation & help, Edward. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/