#!/usr/bin/python2.3 -u
import sys
import cgitb; cgitb.enable()
import MySQLdb

sys.stderr = sys.stdout
print "Content-Type: text/html\n\n"

conn = MySQLdb.connect(user="xxx",passwd="xxx") # actual values concealed
curr = conn.cursor()
numrecs = curr.execute("select statename, abbrev, postal, capital from states;")
recs = curr.fetchall()

print "<html>"
print "<head><title>Contents of states table</title></head>"
print "<body>"
print '<table width="400" border="0" align="center">'

for record in recs:
    print '<tr><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>' % record

print "</table>"

print '<div align="center">'
print "<a href='../ocn/geoquiz.html'>Return to geoquiz home page</a>"
print "</div>"

print "</body>"
print "</html>"
# code highlighted using py2html.py version 0.8