多个复选框Python HTML SQL
我有多个复选框,我希望允许用户选择多个复选框并显示结果:以下是HTML:多个复选框Python HTML SQL,python,html,sql,checkbox,Python,Html,Sql,Checkbox,我有多个复选框,我希望允许用户选择多个复选框并显示结果:以下是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&l
<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"/>
b
c
d
e
这里是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()
form=cgi.FieldStorage()
my_a=form.getlist(“a”)
db=MySQLdb.connect(host=“127.0.0.1”,user=“root”,passwd=“”,db=“project”)
cursor=db.cursor()
打印“a(s)的结果:
”
sql=“从表名中选择*,其中a='%s'”(my_a)
cursor.execute(sql)
rows=cursor.fetchall()
对于行中的行:
打印行
打印“
”
db.close()
有人能帮忙吗?我想我可能需要一个回路,但怎么做?在哪里?谢谢,到底是什么问题?我猜你问的是
SQL
sIN
operator?你问的根本不清楚。当您根据用户选择的复选框查询数据库时,是否没有得到正确的结果?