#!/usr/bin/env python
# Import modules for CGI handling
import cgi, cgitb
cgitb.enable()    

print "content-type:text/html\r\n\r\n"

#print ("Hello World")
filename = 'select.html'
f = open(filename, "r").read()
print f


import pymysql

conn = pymysql.connect(
	host="localhost", 
	user = "root", 
	passwd="netweb",
	database="BROWSEDATA"
	)

mycursor = conn.cursor()


mycursor.execute("select * from GENE_ANNOTATION  LIMIT 1000 ")

result = mycursor.fetchall() 


print ("<table border='1' style ='background-color: #b8d7b4';>")
print ("<tr>")

print ("<th> SEQ_NAME </th>")
print ("<th> SOURCE </th>")
print ("<th> FEATURE </th>")
print ("<th> START </th>")
print ("<th> END  </th>")
print ("<th> SCORE </th>")
print ("<th> STRAND </th>")
print ("<th> FRAME </th>")
print ("<th> ATTRIBUTE </th>")

print ("</tr>")


for each in result:
	print ("<tr>")
	print ("<td>{0}</td>" .format(each[0]))
	print ("<td>{0}</td>" .format(each[1]))
	print ("<td>{0}</td>" .format(each[2]))
	print ("<td>{0}</td>" .format(each[3]))
	print ("<td>{0}</td>" .format(each[4]))
	print ("<td>{0}</td>" .format(each[5]))
	print ("<td>{0}</td>" .format(each[6]))
	print ("<td>{0}</td>" .format(each[7]))
	print ("<td>{0}</td>" .format(each[8]))
	print ("</tr>")
	
print("</table>")

