Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

using CGI, DBI and HTML::Template (a mini tutorial with example code)

by gav^ (Curate)
on Feb 09, 2002 at 04:13 UTC ( [id://144315]=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    <form action="color.pl" method="post">
    <p>Your name: <input type="text" name="name" 
    ...
      value="<TMPL_VAR NAME=COLOR>"></p>
    <p><input type="submit"></p>
    </form>
    
  2. or download this
    <p>Hello, <b><TMPL_VAR NAME=NAME></b>. A little
    birdy told me your favorite color is <b><TMPL_VAR NAME=COLOR></b>.
    
  3. or download this
    use CGI;
    use HTML::Template;
    ...
    
    my $t = HTML::Template->new(filename => "$template.tmpl", associate =>
    + $cgi);
    print $t->output;
    
  4. or download this
    use DBI;
    use CGI;
    ...
    
    print $cgi->header;
    print $t->output;
    
  5. or download this
    <table border="1">
    <tr><th>ID</th><th>NAME</th><th>PRICE</th></tr>
    ...
    </TMPL_LOOP>
    
    </table>
    
  6. or download this
    [snip]
    
    ...
    }
    
    $t->param(ROWS => $rows, TOTAL => $sum);
    
  7. or download this
    <table border="1">
    <tr><th>ID</th><th>NAME</th><th>PRICE</th></tr>
    ...
    </table>
    
    <p>The total is <TMPL_VAR NAME=TOTAL></p>
    
  8. or download this
    use DBI;
    use CGI;
    ...
    print $t->output;
    
    $dbh->disconnect;
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlmeditation [id://144315]
Approved by root
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others examining the Monastery: (5)
As of 2024-04-19 00:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found