asked on
#!C:\Python34\python.exe
import json
import traceback
import cgi,cgitb
import mysql.connector as conn
import collections
import datetime
import shelve
import copy
def htmlTop():
print("""Content-type:text/html\n\n
<!DOCTYPE html>
<html lang="en">
<head>
<style>
body {
font-size: 100%; /*to support em text sizing*/
margin-top: 0;
}
#backgrd_repeat_image {
background-image: url(images/background.png);
background-position: left top;
background-repeat: repeat;
height: 1cm; /*padding-top: 15px;*/
}
</style>
<meta charset="UTF-8">
<title> Welcomme</title>
<link href="registration.css" rel="stylesheet" type="text/css">
</head>
""")
def htmlTail():
print(""" its done</body>
</html>""")
def connectDB():
db=conn.connect(host='localhost' ,user='root' ,passwd='844cheminduplan' ,db='python_office')
cursor = db.cursor()
return db, cursor
def enrollments(db,cursor):
sql = "select memberID,T1ytdlatest,T2ytdlatest,T3ytdlatest from registrations;"
cursor.execute(sql)
results=cursor.fetchall()
return results
#main program
if __name__== "__main__":
try:
htmlTop()
db, cursor = connectDB()
results = enrollments(db,cursor)
for each in results:
test = eval(each[1]) + eval(each[3]) + eval(each[2])
test = list(set(test))
member = each[0]
test = [member] + test
print(test)
htmlTail()
except:
cgi.print_exception()