Hi Rob,
 
Basically I want the data displayed in a table, for example (missed out Euros):
 
  <table>    <tr><td>Sterling</td><td>Dollars</td><td>Euros</td></tr>    <tr>   
   <td>Sterling to Euros</td><td>1.5</td><td>Dollars to 
Sterling</td><td>1.98</td><td>Euros to Sterling</td><td>0.72</td>    </tr>    
<tr>     <td>Sterling to Dollars</td><td>2.05</td><td>Dollars to 
Euros</td><td>0.75</td><td>Euros to Dollars</td><td>1.52</td>    </tr>  
</table> 
Here's my template loop:
 
         <tmpl_loop name=LOOP>          <tmpl_loop name=sterling>  <tr>         
                      <input type="hidden" name="id" value="<tmpl_var 
name=id>">                  <td width="50%" height="22"><p><b><tmpl_var 
name=name></b></p></td>                  <td width="50%" height="22"><input 
type="text" name="rate" size="5" value="<tmpl_var name=rate>"></td>
             </tmpl_loop>                       <tmpl_loop name=dollars>        
                    <input type="hidden" name="id" value="<tmpl_var name=id>">  
                <td width="50%" height="22"><p><b><tmpl_var 
name=name></b></p></td>                  <td width="50%" height="22"><input 
type="text" name="rate" size="5" value="<tmpl_var name=rate>"></td>             
</tmpl_loop>              <tmpl_loop name=euros>                 <input 
type="hidden" name="id" value="<tmpl_var name=id>">                  <td 
width="50%" height="22"><p><b><tmpl_var name=name></b></p></td>                 
 <td width="50%" height="22"><input type="text" name="rate" size="5" 
value="<tmpl_var name=rate>"></td>                         </tmpl_loop>         
</tmpl_loop> 
 
 
 
 
Which produces:
 
 
 
<table>    
<tr><td>Sterling</td><td></td><td>Dollars</td><td></td><td>Euros</td><td></td></tr>
                             <tr>                               <input 
type="hidden" name="id" value="2">                  <td width="50%" 
height="22"><p><b>Sterling -> Euros</b></p></td>                  <td 
width="50%" height="22"><input type="text" name="rate" size="5" 
value="1.5"></td>
               <tr>                               <input type="hidden" 
name="id" value="4">                  <td width="50%" 
height="22"><p><b>Sterling -> Dollars</b></p></td>                  <td 
width="50%" height="22"><input type="text" name="rate" size="5" 
value="2.05"></td>
               <tr>                               <input type="hidden" 
name="id" value="14">                  <td width="50%" 
height="22"><p><b>Sterling -> Malaysian Ringgit</b></p></td>                  
<td width="50%" height="22"><input type="text" name="rate" size="5" 
value="6.47"></td>
                                                                <input 
type="hidden" name="id" value="1">                  <td width="50%" 
height="22"><p><b>Dollars -> Sterling</b></p></td>                  <td 
width="50%" height="22"><input type="text" name="rate" size="5" 
value="1.98"></td>                                         <input type="hidden" 
name="id" value="3">                  <td width="50%" height="22"><p><b>Dollars 
-> Euros</b></p></td>                  <td width="50%" height="22"><input 
type="text" name="rate" size="5" value="0.75"></td>                             
            <input type="hidden" name="id" value="16">                  <td 
width="50%" height="22"><p><b>Dollars -> Malaysian Ringgit</b></p></td>         
         <td width="50%" height="22"><input type="text" name="rate" size="5" 
value="3.22"></td>                                            <input 
type="hidden" name="id" value="5">                  <td width="50%" 
height="22"><p><b>Euro -> Sterling</b></p></td>                  <td 
width="50%" height="22"><input type="text" name="rate" size="5" 
value="0.72"></td>                                          <input 
type="hidden" name="id" value="6">                  <td width="50%" 
height="22"><p><b>Euro -> Dollars</b></p></td>                  <td width="50%" 
height="22"><input type="text" name="rate" size="5" value="1.52"></td>          
                                <input type="hidden" name="id" value="15">      
            <td width="50%" height="22"><p><b>Euro -> Malaysian 
Ringgit</b></p></td>                  <td width="50%" height="22"><input 
type="text" name="rate" size="5" value="5.15"></td>
</table>
 
 
The first (Sterling) column is correct, I can't just add new <tr> tags as it 
would just create a list instead of tablulate the data.  I actually have three 
array refs of data as I have three db queries, each organising the data by 
currency type:
 
 
  $html->param(LOOP => [                            {                           
     sterling =>  $sterlingaref,                               dollars =>  
$dollarsaref,                               euros => $euroaref                  
                             },                         ],                  );
 
 
 
I don't think it's being displayed correctly because the loops maybe should be 
nested, I'm not sure on that and not sure how to do it exactly.  I've RTFM but 
no luck.
 
 
Any help you can give me on this would be greatly appreciated.
 
 
Thank you,
 
Graeme
 
> Date: Tue, 15 Jul 2008 17:37:14 +0100> From: [EMAIL PROTECTED]> To: 
> beginners@perl.org> CC: [EMAIL PROTECTED]> Subject: Re: template loop 
> problem> > > Graeme McLaren wrote:> > Hi all, I'm tryin to do something 
> simple. The output I want needs to be in a table, for example:> > > > 
> <table>> > <tr>> > <td>Euros</td><td>dollars</td>> > </tr>> > <tr> <td>euro 
> value</td><td>dollar value</td>> > > > </tr>> > </table>> > > > > > In my 
> code I have:> > > > $html->param(LOOP => [ { sterling => $sterlingaref, }, ], 
> );> > > > $sterlingaref has the following data structure:> > > > $VAR1 = [ { 
> 'rate' => '1.5', 'name' => 'Sterling -> Euros', 'id' => '2' }, { 'rate' => 
> '2.05', 'name' => 'Sterling -> Dollars', 'id' => '4' }, { 'rate' => '6.47', 
> 'name' => 'Sterling -> Malaysian Ringgit', 'id' => '14' } ];> > > > > > > > 
> Any ideas how to display this properly?> > I'm not sure what you mean Graeme. 
> You seem to want to display a table of> equivalent values in euros and 
> dollars but all you have shown us is a structure> of exchange rates. What are 
> the actual amounts that should appear in the table?> > Rob> > -- > To 
> unsubscribe, e-mail: [EMAIL PROTECTED]> For additional commands, e-mail: 
> [EMAIL PROTECTED]> http://learn.perl.org/> > 

Reply via email to