Perl/MySQL/TT
Scott McWhirter
sleepy_uk at hotmail.com
Mon Oct 29 07:55:46 CST 2001
>Can anyone give me a few pointers as to how to
>get the data passed to the template in the right way?
Here is a way i do it:
--------------------------------------------------
######################################################
# $fds is a hash reference of rows of data in a table
######################################################
foreach my $d (sort keys %{$fds}){
my $name = $fds->{"$d"}{"name"};
my $pic = $fds->{"$d"}{"pic"};
my $dob = $fds->{"$d"}{"dob"};
my $vars = {
name => $name,
pic => $pic,
dob => $dob
};
###############################################
# $t->template_by_name(); gets a template from
# a table.
###############################################
my $template = $t->template_by_name('fritab');
###############################################
# $t->give_me_html(); gives me html from the
# processed template with $vars
###############################################
$html .= $t->give_me_html($template,$vars);
}
--------------------------------------------------
the template(fritab) for example is just:
>>[% name %] birthdate is [% dob %] and this is what they look like
<img src="[% pic %]"><br><<
so for each different row it will print out each persons info.
hope it helps!
--
-Scott McWhirter- | -kungfuftr-
PGP key id: 0x3C79CF1D
_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp
More information about the Belfast-pm
mailing list