Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/html/79.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
多个复选框Python HTML SQL_Python_Html_Sql_Checkbox - Fatal编程技术网

多个复选框Python HTML SQL

多个复选框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

我有多个复选框,我希望允许用户选择多个复选框并显示结果:以下是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"/>

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
s
IN
operator?你问的根本不清楚。当您根据用户选择的复选框查询数据库时,是否没有得到正确的结果?