Re: [htmltmpl] MySQL -> HTML::Template
Brought to you by:
samtregar
From: Kenneth G. <la...@th...> - 2003-11-18 03:50:56
|
On Monday 17 November 2003 23:57, Chris wrote: > Thanks for the link, it helped me very much! > > Now once again im stuck... > > How do I do nested loops?? > > Using the perlmonks example: > > <TMPL_LOOP ROWS> > <tr bgcolor="#<TMPL_IF ODD>666666<TMPL_ELSE>EEEEEE</TMPL_IF>"> > <td><TMPL_VAR NAME=ID></td> > <td><TMPL_VAR NAME=NAME></td> > <td><TMPL_VAR NAME=PRICE></td> > </tr> > </TMPL_LOOP> > > If I wanted to do say: > > <TMPL_LOOP ROWS> > <tr bgcolor="#<TMPL_IF ODD>666666<TMPL_ELSE>EEEEEE</TMPL_IF>"> > <td><TMPL_VAR NAME=ID></td> > <TMPL_LOOP INNERROWS> > <TMPL_VAR NAME=SUBID> > </TMPL_LOOP> > <td><TMPL_VAR NAME=NAME></td> > <td><TMPL_VAR NAME=PRICE></td> > </tr> > </TMPL_LOOP> > > > For the life of me, I can't figure out how to do it... > > I have repeatedly destroyed my own code, so I will use the perlmonks > code.. > > This is what I have been trying, is it even *close* to right??? > > while ($sth->fetch) { > my $real_price = $price < $saleprice ? $price : $saleprice; > $name =~ s/\b(\w)(\w+)\b/\U$1\L$2/g; > push @rows, { ID => lc($id), PRICE => $real_price, NAME => $name, > +ODD => $i++ %2 }; > $sum += $real_price; > while ($sth2->fetch) { > push @innerrows, { SUBID => $sub_id }; > } > } @innerrows should be pushed into @rows -- regards kg http://www.ootygolfclub.org |