#!/usr/bin/perl use DBI; &parseForm; &loadCookie; my $docroot = "$ENV{DOCUMENT_ROOT}"; my $hostname = "sqlc0e.megasqlservers.com"; my $db = "focl_friendsofclearlake_com"; my $user = "dbm.friendsofclearlake.com"; my $password = "tslv01"; #pass for ssh is laurie my $senQuery = "SELECT * FROM senator ORDER BY lname"; my $repQuery = "SELECT * FROM representative ORDER BY lname"; my $dsn = "DBI:mysql:database=$db;host=$hostname"; $dbh = DBI->connect($dsn, $user, $password); if ($dbh) { print "Content-type: text/html\n\n"; &pageHeader; &mainDisplay; &pageFooter; $dbh->disconnect(); exit; } else { print "Content-type: text/html\n\n"; $legislator = 0; &pageHeader; print "
This section is under maintenance, please try again later.
"; &pageFooter; exit; } sub mainDisplay { $moreInfo = qq~You can also find out more information about your legislators at www.legis.state.ia.us.
~; if ($input{wd} eq "sen") { $query = qq~ SELECT * FROM senator ORDER BY home_county ASC, lname ASC ~; $bgcolor = 0; $sth = $dbh->prepare_cached($query); $sth->execute(); while (my $senator = $sth->fetchrow_hashref()) { if (!$bgcolor) { $bg = qq~ bgcolor="#eeeeee"~; $bgcolor = 1; } else { $bg = qq~ bgcolor="#ffffff"~; $bgcolor = 0; } $senList .= qq~
List of Senators:
The list below is sorted by Senators\' Home County and Last Name.
| Last Name, First Name | Home County | District | Party |
~; } elsif ($input{wd} eq "rep") { $query = qq~ SELECT * FROM representative ORDER BY home_county ASC, lname ASC ~; $bgcolor = 0; $sth = $dbh->prepare_cached($query); $sth->execute(); while (my $senator = $sth->fetchrow_hashref()) { if (!$bgcolor) { $bg = qq~ bgcolor="#eeeeee"~; $bgcolor = 1; } else { $bg = qq~ bgcolor="#ffffff"~; $bgcolor = 0; } $senList .= qq~
List of Representatives:
The list below is sorted by Representatives\' Home County and Last Name.
| Last Name, First Name | Home County | District | Party |
~; } else { print qq~
You can view the list of all Senators or Representatives by clicking on the corresponding link below:
$moreInfo ~; } } sub pageHeader { if ($legislator) { $atLeg = qq~class="active"~; $atForm = "";} if (!$legislator) { $atLeg = qq~~; $atForm = qq~class="active"~; } print qq~
Legislators~; } sub pageFooter { print qq~ |