#!./perl -w #!/usr/local/bin/perl5 -w ########################################################################### ### $Id: //depot/personal/ryan/optimism.cc/music.3/composer_work.cgi#2 $ ########################################################################### ### Display the list of composers ########################################################################### ### Unbuffer stdout to make life faster $|=1; ### Need to be able to see errors open(STDERR, ">&STDOUT"); ### Take care of the header before anything goes wrong print "Content-type: text/html\n\n"; ### Load in modules use strict; ### Prevent typos use music::db; ### DB routines use music::display; ### HTML routines use CGI; my( $cgi, $dbh, @row, $rec, $sth, $sth2, $name, $id); my( $artist, $conductor, $musician, $title); my( %count, $count, $min); $cgi = new CGI; if( !defined( $cgi->param("comp_id"))) { ### print out the nifty header &DisplayHeader( "Composer Works", ""); print "ERROR: Whoops no composer specified\n"; exit; } ### Connect to the server $dbh = &Connect(); $artist = &GetArtistInfo( $dbh, $cgi->param("comp_id"), "name"); ### print out the nifty header &DisplayHeader( "Works of $artist", ""); ### Create and execute query $sth = $dbh->prepare("SELECT * FROM works WHERE comp_id=" . $cgi->param("comp_id") . " AND p_work_id=0 ORDER BY title") || die $dbh->errstr; $sth->execute || die $dbh->errstr; print "\n"; #print "\n"; $min = int( $sth->rows/2)+1; ### Fetch the results for( $count=0;defined((@row = $sth->fetchrow_array)[0]);$count++) { $id = $row[0]; $name = $row[2]; # $name =~ s/\s/ /g; if( $count > 0 && $count%$min == 0) { print ""; print "
My Composers
 \n"; } if( $count%$min == 0) { print "\n"; print "\n"; print "";# if( $count%2 == 0); # print "\n"; } print "
"; } # print "
$name\n"; print "
  • $name\n"; # print "
  • \n"; $sth->finish; ### Log off from the server $dbh->disconnect;