Other Applications 43
for albumInfo in albums:
currentAlbum = album(albumInfo)
tableRows.append(currentAlbum.tableRow())
table = "\n"
table += "\n".join(tableRows)
table += "
\n"
else:
table = "

Unable to acquire albums

\n"
else:
table = "

Unable to connect to database " + self.db + ".

\n";
return table
def page(self):
page = "\n"
page += "My Albums\n"
page += "\n"
page += "

My Albums

\n"
page += self.table()
page += "\n"
page += "\n"
return page
albumList = albums( U
SERNAME
 ,  P
ASSWORD
 )
print albumList.page()
Perl
Perl requires the DBI database interface to connect to MySQL. You can get it from CPAN:
perl  MCPAN  e shell
install dbi
install DBD::mysql
This will get you the DBI interface and the MySQL information it needs to work.
#!/usr/bin/perl
use DBI;
$driver = "mysql";
$host = "localhost";
$port = 3306;
$user = "U
SERNAME
";
$pass = "P
ASSWORD
";
$database = "music";
$query = "SELECT album, artist, year, rating FROM albums ORDER BY artist";
$dataSource = "DBI:$driver:database=$database;host=$host;port=$port";
print "\n";
print "My Albums\n";
print "\n";
print "

My Albums

\n";
print "\n";
print "
\n";
if ($databaseHandle = DBI >connect($dataSource, $user, $pass)) {
if ($queryHandle = $databaseHandle >prepare($query)) {
if ($queryHandle >execute) {
while ($rowHandle = $queryHandle >fetchrow_hashref()) {




  
AlbumArtistYearRating

Home

About Services Network Support FAQ Order Contact
 

Php MySQL Web Hosting

Our partners:Jsp Web Hosting Unlimited Web Hosting Cheapest Web Hosting  Java Web Hosting Web Templates Best Web Templates PHP Mysql Web Hosting Interland Web Hosting Cheap Web Hosting PHP Web Hosting Tomcat Web Hosting Quality Web Hosting Best Web Hosting  Mac Web Hosting 

Lunarwebhost.net  Business web hosting division of Vision Web Hosting Inc. All rights reserved