我有多个复选框,我想允许用户选择多个并显示结果:这是 HTML:
<form action= "antisearch.py">
<input type="checkbox" name="a" value="b">b<br>
<input type="checkbox" name="a" value="c">c<br>
<input type="checkbox" name="a" value="d">d<br>
<input type="checkbox" name="a" value="e">e<br>
<input type= submit value = "Search"/> <input type= reset value = "Clear"/>
这是python 2.7
form =cgi.FieldStorage()
my_a=form.getlist("a")
db = MySQLdb.connect(host="127.0.0.1",user="root",passwd="", db="project")
cursor=db.cursor()
print "Results for the a(s) : <br>"
sql = "select * FROM table name where a= '%s'" %(my_a)
cursor.execute(sql)
rows = cursor.fetchall()
for row in rows:
print row
print "<br>"
db.close()
任何人都可以帮忙吗?