Hi,
Short and to the point.
1. I'm using this script to dump information from a database (and it works,
yes :).
dump.pl
-----------------------------------------------------------------
#!/usr/bin/perl
use CGI qw/:standard :html3/;
use CGI::Carp qw(fatalsToBrowser);
use DBI;
use DBD::mysql;
my $DBName = "test";
my $DBHost = "localhost";
my $DBUser = "test";
my $DBPass = "dev";
my $DBType = "mysql";
my $DBPort = "3306";
sub db_connect {
my ($result);
$result = DBI->connect( "DBI:$DBType:database=$DBName;host=$DBHost",
"$DBUser", "$DBPass", { 'RaiseError' => 0 } ) || &error("Unable to
connect to database");
return $result;
}
sub db_query {
my ($result, $query);
$query = $_[0];
$result = &db_connect->prepare($query) || &error("Unable to query the
database");
$result->execute();
return $result;
}
# outer loop
my $query1 = &db_query("SELECT id, title FROM sections");
while (my $rows1 = $query1->fetchrow_hashref()) {
print "Section: " . $rows1->{title}."\n";
my $sectionid = $rows1->{id};
# inner loop
my $query2 = &db_query("SELECT title FROM pages WHERE sectionid =
$sectionid");
while (my $rows2 = $query2->fetchrow_hashref()) {
print "-> Page: " . $rows2->{title}."\n";
}
}
-----------------------------------------------------------------
2. Since I have started using HTML::Template on my webpage, I have to port
this script to get use of a template.
The template looks something like this:
dump.html
-----------------------------------------------------------------
<TMPL_LOOP NAME="SECTIONS">
Section: <TMPL_VAR NAME="TITLE"><br>
<TMPL_LOOP NAME="PAGES">
-> Page: <TMPL_VAR NAME="TITLE"><br>
</TMPL_LOOP>
</TMPL_LOOP>
3. I have tried to make a new script for HTML::Template, but I can't get the
script working with the template because of the outer/inner loop.
Somebody out there with a solution? :-)
Regards, Eivind Hestnes
-------------------------------------------------------
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