if ($range eq "old") { $addressField = "oldAddressSort"; $streetField = "oldAddress"; }else { $addressField = "newAddressSort"; $streetField = "newAddress"; }# Allows the user to switch back and forth between old address (pre-1907) and new address (post-address)$queryaddress = "SELECT * FROM `addressMaster` WHERE $addressField = '$address' AND $streetField = '$street'";my $sth = $dbh->prepare($queryaddress);$sth->execute();($oldStreetNumber,$newStreetNumber,$oldAddress,$newAddress,$oldAddressSort,$newAddressSort,$uida) = $sth->fetchrow();# The above code simply finds the old and new street numbers and names for the indicated propertyif ($oldStreetNumber eq "") {	$addressText = "No records found for this property.";	$oldAddress = $street;	$oldStreetNumber = $address;}else { $addressText = "Before 1907, this property was at $oldStreetNumber $oldAddress. It is now $newStreetNumber $newAddress." }$imageFileName = $newAddressSort . $newAddress;$imageFileName =~ tr/ //d;$imageFileName = $imageFileName . ".jpg";$imageFileName =~ tr/A-Z/a-z/;# If we have a photo of the property from the 2000 AIC project, this will determine its name for subsequent display$query = "SELECT recordID FROM houseDocumentation WHERE address='$newStreetNumber' AND street='$newAddress'";my $sth = $dbh->prepare($query);$sth->execute();$xmlFile = $sth->fetchrow();$sth->finish();$housingSurveyStr = "";if ($xmlFile) { $housingSurveyStr = "<a class=\"centeredObject\" href=\"/cgi-bin/pvm/housingSurveyMenuViews2.pl?address=$newStreetNumber&street=$newAddress\">2000 Survey</a>" }# If we have a 2000 AIC survey for the property, then build a link to a CGI program that will display it# I am skipping some code here, which simply builds up the headers to create a dynamic web page# Now iterate through the 4 data sources for demographic data (1883 and 1889 city directories, 1900 census, and 1916 phone book<h3 class="displayBanner">	1883 City Directory</h3><p /><table border="1">EOF# I will repeat this code as many times as necessary to retrieve all the names of the people who lived or worked at this address.$querya = "SELECT * FROM `census` WHERE street = '$oldAddress' AND address = '$oldStreetNumber' AND source = '1883 City Directory' ORDER BY lastName, firstName";my $sth = $dbh->prepare($querya);$sth->execute();while (@ADDRESS = $sth->fetchrow()) { &getValues }print <<EOF;</table><p /><h3 class="displayBanner">	1889 City Directory</h3><p /><table border="1">EOF$querya = "SELECT * FROM `census` WHERE street = '$oldAddress' AND address = '$oldStreetNumber' AND source = '1889 City Directory' ORDER BY lastName, firstName";my $sth = $dbh->prepare($querya);$sth->execute();while (@ADDRESS = $sth->fetchrow()) { &getValues }print <<EOF;</table><p /><h3 class="displayBanner">	1900 Census</h3><p /><table border="1">EOF$querya = "SELECT * FROM `census` WHERE street = '$oldAddress' AND address = '$oldStreetNumber' AND source = '1900 Census' ORDER BY lastName, firstName";my $sth = $dbh->prepare($querya);$sth->execute();while (@ADDRESS = $sth->fetchrow()) { &getValues }print <<EOF;</table><p /><h3 class="displayBanner">	1916 Phone Book</h3><p /><table border="1">EOF$querya = "SELECT * FROM `census` WHERE street = '$oldAddress' AND address = '$oldStreetNumber' AND source = '1916 Phone Book' ORDER BY lastName, firstName";my $sth = $dbh->prepare($querya);$sth->execute();while (@ADDRESS = $sth->fetchrow()) { &getValues }print <<EOF;<p /></table>EOFgetFooter();print "</body>\n</html>\n";$dbh->disconnect;# The routine getValues retrieves individual records from the SQL SELECT statement above and formats them into HTMLsub getValues {        $address = $ADDRESS[0]; $aptNumber = $ADDRESS[1];        $street = $ADDRESS[2]; $lastName = $ADDRESS[3];        $firstName = $ADDRESS[4]; $occupation = $ADDRESS[5];        $ownOrBoard = $ADDRESS[6]; $recordID = $ADDRESS[7];        $source = $ADDRESS[8]; $uid = $ADDRESS[8];        if (($address ne "") and ($street ne $oldAddress)) {                $dispstreet = $street;                $street =~ s/th//g;                $street =~ s/ /%20/g;                $address = "<br />Lived at: <a href=\"/cgi-bin/pvm/houseHistoryGetAddress.pl?range=old&street=" . $street . "&address=" . $address . "\">$address $dispstreet</a>";        }        else { $address = "" }        if ($firstName ne "") { $nameOfPerson = $lastName . ", " . $firstName }        else { $nameOfPerson = $lastName }        $aptNumber =~ s/Room//g;        if ($aptNumber ne "") { $nameOfPerson = $nameOfPerson . " Room " . $aptNumber }        if ($ownOrBoard eq "R") { $ownOrBoard = "Primary Renter." }        elsif ($ownOrBoard eq "B") { $ownOrBoard = "Boarder." }        elsif ($ownOrBoard eq "U") { $ownOrBoard = "" }        if ($source eq "1900 Census") { $recordID = "<a href=\"/cgi-bin/pvm/houseHistoryDisplay1900Census.pl?fileName=1900Census." . $recordID . ".xml\">More...</a>" }# Builds a More… link that points to an external XML file, 1900Census.$recordID.xml.        else { $recordID = "" }        print <<WOMBAT;                <tr>                        <td width="20%"><span class="nameText">$nameOfPerson</span></td><td width="40%"><span class="italictext">$occupation</span></td><td class="40%"><span class="rentOrBoardText">$recordID $address</span></td>                </tr>WOMBAT}