Although I've taken the rest of the year off, I wanted to share a few fun classics this week. "Now That is a Way to do States" was originally published on 2005-01-31, and amazingly, no one has submitted a worse way to "do states" to this day...
It's hard to believe, but a good seven months ago, I honestly thought that using an autonumber as the primary key (instead of OH, NY, etc) was a bad way of implementing a States table in a database. Of course, thanks to everyone who's submitted things over the months (you guys rock, by the way), tblState would simply have been tossed in the "not using best-practices" category. But I think we can all agree that this state-handling routine from Kurt Payne would definitely fit in the Whisky Tango Foxtrot category ...
while ($AppSub <= $#FILE) { $AppLine = @FILE[$AppSub]; @data = split(/\|/, $AppLine); $AppDisplayName = @data[0]; # Look for the Quick App record if ($AppDisplayName eq "Contact Us Form") { # Now read the 55 records $AppTitle = @data[0]; $AppProg = @data[1]; $AppSuccess = @data[2]; $AppEmail = @data[3]; $Alabama = @data[4]; $Alaska = @data[5]; $Arizona = @data[6]; $Arkansas = @data[7]; $California = @data[8]; $Colorado = @data[9]; $Connecticut = @data[10]; $Delaware = @data[11]; $DC = @data[12]; $Florida = @data[13]; $Georgia = @data[14]; $Hawaii = @data[15]; $Idaho = @data[16]; $Illinois = @data[17]; $Indiana = @data[18]; $Iowa = @data[19]; $Kansas = @data[20]; $Kentucky = @data[21]; $Louisiana = @data[22]; $Maine = @data[23]; $Maryland = @data[24]; $Massachusetts = @data[25]; $Michigan = @data[26]; $Minnesota = @data[27]; $Mississippi = @data[28]; $Missouri = @data[29]; $Montana = @data[30]; $Nebraska = @data[31]; $Nevada = @data[32]; $NewHampshire = @data[33]; $NewJersey = @data[34]; $NewMexico = @data[35]; $NewYork = @data[36]; $NorthCarolina = @data[37]; $NorthDakota = @data[38]; $Ohio = @data[39]; $Oklahoma = @data[40]; $Oregon = @data[41]; $Pennsylvania = @data[42]; $RhodeIsland = @data[43]; $SouthCarolina = @data[44]; $SouthDakota = @data[45]; $Tennessee = @data[46]; $Texas = @data[47]; $Utah = @data[48]; $Vermont = @data[49]; $Virginia = @data[50]; $Washington = @data[51]; $WestVirginia = @data[52]; $Wisconsin = @data[53]; $Wyoming = @data[54]; } $AppSub++; } #ED: and later on in the code ...
print HTML "State: <select name=\"Property_State\" size=\"1\">\n"; print HTML "<option value=\"\"> </option> \n"; if ($Alabama eq "1") { print HTML "<option value=\"Alabama\">Alabama</option> \n"; } if ($Alaska eq "1") { print HTML "<option value=\"Alaska\">Alaska</option> \n"; } if ($Arizona eq "1") { print HTML "<option value=\"Arizona\">Arizona</option> \n"; } if ($Arkansas eq "1") { print HTML "<option value=\"Arkansas\">Arkansas</option> \n"; } if ($California eq "1") { print HTML "<option value=\"California\">California</option> \n"; } if ($Colorado eq "1") { print HTML "<option value=\"Colorado\">Colorado</option> \n"; } if ($Connecticut eq "1") { print HTML "<option value=\"Connecticut\">Connecticut</option> \n"; } if ($Delaware eq "1") { print HTML "<option value=\"Delaware\">Delaware</option> \n"; } if ($DC eq "1") { print HTML "<option value=\"District of Columbia\">District of Columbia</option> \n"; } if ($Florida eq "1") { print HTML "<option value=\"Florida\">Florida</option> \n"; } if ($Georgia eq "1") { print HTML "<option value=\"Georgia\">Georgia</option> \n"; } if ($Hawaii eq "1") { print HTML "<option value=\"Hawaii\">Hawaii</option> \n"; } if ($Idaho eq "1") { print HTML "<option value=\"Idaho\">Idaho</option> \n"; } if ($Illinois eq "1") { print HTML "<option value=\"Illinois\">Illinois</option> \n"; } if ($Indiana eq "1") { print HTML "<option value=\"Indiana\">Indiana</option> \n"; } if ($Iowa eq "1") { print HTML "<option value=\"Iowa\">Iowa</option> \n"; } if ($Kansas eq "1") { print HTML "<option value=\"Kansas\">Kansas</option> \n"; } if ($Kentucky eq "1") { print HTML "<option value=\"Kentucky\">Kentucky</option> \n"; } if ($Louisiana eq "1") { print HTML "<option value=\"Louisiana\">Louisiana</option> \n"; } if ($Maine eq "1") { print HTML "<option value=\"Maine\">Maine</option> \n"; } if ($Maryland eq "1") { print HTML "<option value=\"Maryland\">Maryland</option> \n"; } if ($Massachusetts eq "1") { print HTML "<option value=\"Massachusetts\">Massachusetts</option> \n"; } if ($Michigan eq "1") { print HTML "<option value=\"Michigan\">Michigan</option> \n"; } if ($Minnesota eq "1") { print HTML "<option value=\"Minnesota\">Minnesota</option> \n"; } if ($Mississippi eq "1") { print HTML "<option value=\"Mississippi\">Mississippi</option> \n"; } if ($Missouri eq "1") { print HTML "<option value=\"Missouri\">Missouri</option> \n"; } if ($Montana eq "1") { print HTML "<option value=\"Montana\">Montana</option> \n"; } if ($Nebraska eq "1") { print HTML "<option value=\"Nebraska\">Nebraska</option> \n"; } if ($Nevada eq "1") { print HTML "<option value=\"Nevada\">Nevada</option> \n"; } if ($NewHampshire eq "1") { print HTML "<option value=\"New Hampshire\">New Hampshire</option> \n"; } if ($NewJersey eq "1") { print HTML "<option value=\"New Jersey\">New Jersey</option> \n"; } if ($NewMexico eq "1") { print HTML "<option value=\"New Mexico\">New Mexico</option> \n"; } if ($NewYork eq "1") { print HTML "<option value=\"New York\">New York</option> \n"; } if ($NorthCarolina eq "1") { print HTML "<option value=\"North Carolina\">North Carolina</option> \n"; } if ($NorthDakota eq "1") { print HTML "<option value=\"North Dakota\">North Dakota</option> \n"; } if ($Ohio eq "1") { print HTML "<option value=\"Ohio\">Ohio</option> \n"; } if ($Oklahoma eq "1") { print HTML "<option value=\"Oklahoma\">Oklahoma</option> \n"; } if ($Oregon eq "1") { print HTML "<option value=\"Oregon\">Oregon</option> \n"; } if ($Pennsylvania eq "1") { print HTML "<option value=\"Pennsylvania\">Pennsylvania</option> \n"; } if ($RhodeIsland eq "1") { print HTML "<option value=\"Rhode Island\">Rhode Island</option> \n"; } if ($SouthCarolina eq "1") { print HTML "<option value=\"South Carolina\">South Carolina</option> \n"; } if ($SouthDakota eq "1") { print HTML "<option value=\"South Dakota\">South Dakota</option> \n"; } if ($Tennessee eq "1") { print HTML "<option value=\"Tennessee\">Tennessee</option> \n"; } if ($Texas eq "1") { print HTML "<option value=\"Texas\">Texas</option> \n"; } if ($Utah eq "1") { print HTML "<option value=\"Utah\">Utah</option> \n"; } if ($Vermont eq "1") { print HTML "<option value=\"Vermont\">Vermont</option> \n"; } if ($Virginia eq "1") { print HTML "<option value=\"Virginia\">Virginia</option> \n"; } if ($Washington eq "1") { print HTML "<option value=\"Washington\">Washington</option> \n"; } if ($WestVirginia eq "1") { print HTML "<option value=\"West Virginia\">West Virginia</option> \n"; } if ($Wisconsin eq "1") { print HTML "<option value=\"Wisconsin\">Wisconsin</option> \n"; } if ($Wyoming eq "1") { print HTML "<option value=\"Wyoming\">Wyoming</option> \n"; } print HTML "</select> \n";