def form_stations(): stations = functs.stations() print '<tr><th>Select a Station:</th>' print '<td><SELECT name="city" size="6">' for i in range(len(stations)): print '<option value="'+stations[i][1]+'">'+stations[i][0] print '</SELECT></td></tr>'
def search(option, city, year, month, day): results = [] if option == "yearly": print '<BR><a href="graph.py?city='+city+'&year='+year+'">Click Here for a graph of this data</a><BR>' results = mydb.query("SELECT * from "+city+" WHERE yeer = '"+year+"'") results = results.getresult() if option == "monthly": results = mydb.query("SELECT * from "+city+" WHERE yeer = '"+year+"' AND month = '"+month+"'") results = results.getresult() if option == "daily": results = mydb.query("SELECT * from "+city+" WHERE yeer = '"+year+"' AND month = '"+month+"' AND day = '"+day+"'") results = results.getresult() if option == "allstations_daily": stations = functs.stations() # for i in range(len(stations)): for i in range(10): code = stations[i][1] tmp_results = mydb.query("SELECT * from "+code+" WHERE yeer = '"+year+"' AND month = '"+month+"' AND day = '"+day+"'") tmp_results = tmp_results.getresult() results = results + tmp_results return results
#!/usr/local/bin/python # This is the main page for the Iowa archive weather data # Daryl Herzmann 1/14/99 # UPDATED: 4/7/99: Time to add multi-station features import os, style, std_table, calendar, functs from cgi import * stations = functs.stations() def html_setup(): style.header("Historical Iowa Weather Data","white") std_table.blue_top("Historical Iowa Weather Data") std_table.side_setup() options = [('Daily','index.py?opt=daily'),('Monthly','index.py?opt=monthly'),('Yearly','index.py?opt=yearly')] std_table.side_content("One Station Search Options:", options) options = [('Yearly','index.py?opt=graph_yearly'),('Multi-Year','index.py?opt=graph_multiyear')] std_table.side_content("Graphing Options:", options) std_table.side_end() def make_daily(): print '<form method="POST" action="search.py">' print '<input type="hidden" name="query_option" value="daily">' print '<td>' print '<CENTER><H2>Search Archive by Date</H2>' print '<TABLE>'