#!/usr/bin/perl # start.pl: Entry point into the NWR search engine # Created: 19990314 Brendan Cully # Modified: # 20041228 Will Rico # compliance with new branding # use HTML::Template instead of inline HTML # use strict # 20000310 Brendan Cully # graphic size change # 20000225 Brendan Cully # changed disc query for mysql (NULL semantics) # 19990914 Brendan Cully # added search by disc title # 19990531 Brendan Cully # added header graphic, lightened title, wording changes, order changes use strict; use lib '/mnt/web/guide/newworldrecords/libperl'; use CGI::Carp qw(fatalsToBrowser); use CGI qw/:all/; use HTML::Template; use vars qw($dbh); require "libnwr.pl"; use DBI; my( $sql, $sth, $row ); $sql = q{ SELECT genre_id, genre_name FROM genres ORDER BY genre_name }; $sth = $dbh->prepare($sql) || printError($dbh->errstr); $sth->execute() || printError($dbh->errstr); my(@genres); while ($row = $sth->fetch) { my %genre = ( id => $$row[0], name => $$row[1], ); push(@genres, \%genre); } $sql = q{ SELECT composer_id, last_name, first_name FROM composers ORDER BY last_name, first_name }; $sth = $dbh->prepare($sql) || printError($dbh->errstr); $sth->execute() || printError($dbh->errstr); my ($composer_name, @composers); while ($row = $sth->fetch) { $composer_name = $$row[1] . ($$row[2] eq "" ? "" : ", " . $$row[2]); my %composer = ( id => $$row[0], name => $composer_name ); push(@composers, \%composer); } $sql = q{ SELECT catalog_id, disc_title FROM discs WHERE disc_title IS NOT NULL ORDER BY disc_title }; $sth = $dbh->prepare($sql) || printError($dbh->errstr); $sth->execute() || printError($dbh->errstr); # we overload catalog_ids with disc_title so we don't have to requery in # songs.pl - catalog_id first since it's easier to parse my (@catalog); while ($row = $sth->fetch) { my %disc = (id => $$row[0] . "," . $$row[1], title => $$row[1]); push(@catalog, \%disc); } my $template = HTML::Template->new(filename => "search.html"); $template->param( composers => \@composers, catalog => \@catalog, genres => \@genres, ); print header(); print $template->output;