1

複数のチェックボックスがあり、ユーザーが複数を選択して結果を表示できるようにしたい: 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() 

誰でも助けることができますか?

4

0 に答える 0