use DBI; # ¼ÙÈçÄãûÓÐstartup.perlÎļþÔòÐèÒª¼ÙÈç¸ÃÐдúÂë
my $dbh = DBI->connect(\"DBI:mysql:test:localhost\", \"\",\"\")
or die $DBI::errstr;
my $SQL = <<\"EOT\";
select title, released
from albums
where artist = \"Genesis\"
order by released
EOT
my $cursor = $dbh->prepare($SQL);
$cursor->execute;
//
<HTML>
<HEAD><TITLE>ePerl/DBI/HTML Integration
Example</TITLE></HEAD>
<BODY>
<P>
ÓйØGenesis albumsµÄÊý¾Ý¿â³ÌÐò½á¹ûΪ ...
<HR>
<TABLE BORDER>
<TR><TH COLSPAN=2>Albums by Genesis</TH></TR>
<TR><TH>Title</TH><TH>Release
Date</TH></TR>
my @columns;
while ( @columns = $cursor->fetchrow ) {
print ( \"<TR>\",( map { \"<TD>$_</TD>\" }
@columns ) , \"</TR>\\n\");
}
/
</TABLE>
<HR>
<P>
... and that\"s it!
</BODY>
</HTML>
$cursor->finish;
$dbh->disconnect;
//
Äã¿ÉÒԲ鿴¸Ã³ÌÐòÖ´ÐеĽá¹û¡£
Albums by Genesis
Title Release Date
Selling England By The Pound 1973-01-01
Trespass 1974-01-01
A Trick of the Tale 1976-01-01
Wind & Wuthering 1976-01-01
Duke 1980-01-01
We Can\"t Dance 1990-01-01