C Hagstrom wrote:
> I'm hoping for some conceptual help here....
> I have tried to find references to my question without
> success ( the list-archive link appears not to be working).
> 
> 
> I can get the results to print directly with this code:
> 
> $sth = $dbh->prepare ("SELECT * FROM $working_tbl WHERE first='one' ORDER 
> BY Location");
> $sth->execute ();
> while ( my $hash_ref = $sth->fetchrow_hashref ) {
>          print "ID: $hash_ref->{'ID'} -- Name: 
> $hash_ref->{'Name'}  (etc....) <br>\n";
> }
> 
> 
> Now that I am an H::T convert, I'm looking for guidance
> on how best to handle the database output so I can
> take advantage of the <TMPL_LOOP> feature in H::T


you can use something like this to get the structure from DBI

$sth = $dbh->prepare("SELECT FirstName, LastName FROM Person WHERE ...");
#this will get an array of hashrefs
my $result = $sth->fetchall_arrayref({});

then you would put that structure into your template like so...
my $tmpl->HTML::Template->new(..);
$tmpl->param('Person_Loop' => $result);

and then your template could look like this

<TMPL_LOOP Person_Loop>
  Hello, My name is <TMPL_VAR FirstName> <TMPL_VAR LastName>.<br />
</TMPL_LOOP>

Does that help?

Michael Peters
Venzia


-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=1470&alloc_id=3638&op=click
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to