Thanks Andy. i will have a try later as now i am on laptop. i cant test it on laptop now.
just now i look through GT help file again it shows below
Consider the following more complex example, with a
people variable set to the following loop:
Code:
[ { name => "John Doe", age => 35, hair => "no", phone => { work => "(555) 555-5678", home => "(555) 555-6789" } },
{ name => "Jane Doe", age => 25, hair => "brown", phone => { work => "(555) 555-5678", home => "(555) 555-1234" } } ]
The following template code:
<%loop person%><%row_num%>. <%name%>, <%age%> years of age, <%hair%> hair. Phone: work: <%phone.work%>, home: <%phone.home%>. <%endloop%>
The first person on the list, <%person.0.name%>, can be reached at either <%person.0.phone.work%> or <%person.0.phone.home%>.
Will display:
1. John Doe, 35 years of age, no hair. Phone: work: (555) 555-5678, home: (555) 555-6789.
2. Jane Doe, 25 years of age, brown hair. Phone: work: (555) 555-5678, home: (555) 555-1234.
The first person on the list, John Doe, can be reached at either (555) 555-5678 or (555) 555-6789.
From my understand , if i could i could it do in this way
Code:
sub {
my $output;
my $sth = $DB->table('tabletest')->select( { id => "idnumber" } );
while (my $rec = $sth->fetchrow_hashref ) {
$output .= Links::SiteHTML::display('8selecttest', $rec );
}
return $output;
}
let us say there are tree columns in table "tabletest" called id, column1 and orderdetailorderdetail
orderdetails value looks like this {name => 'name111',colour => 'red'},{name => 'name222',colour => 'yellow'}
so i could called it later in the tempalate as
Code:
<%column1%>
<%orderdetail%> ####which will display unreadable data {name => 'name111',colour => 'red'},{name => 'name222',colour => 'yellow'}
or call it
Code:
<%column1%>
<%loop orderdetail%><%row_num%>. <%name%>, <%colour%> <%endloop%>
is that correct?
how could could i creat a loop code in the sub??
Thanks in advance