I have a database in Mysql connected to a web app with flask and python and I am trying to create a general query which will contain values from checkboxes.
html page
<table width="100%">
<tbody>
<tr class="odd gradeX">
<td> <input type="checkbox" name ="check" value="one"> one</td>
<td> <input type="checkbox" name ="check" value="two"> two</td>
<td> <input type="checkbox" name ="check" value="three"> three</td>
</tr>
</tbody>
</table>
the main page
@app.route('/forms',methods = ['GET', 'POST'])
def forms():
form = Attributes()
if request.method == 'POST':
name = request.form.getlist('check')
query = search("SELECT f.ID,Link,PersonID,RoadInfrastructure,RoadType,Dimension,REC,Gender,Glasses FROM dbo.Film f,dbo.Person p WHERE f.REC like '%" + name + "%'", connect())
If I will check all the checkboxes, name will be a list like name=['one','two','three']. How can I use this list in query if I want to find all the REC files with name 'one' and 'two' and 'three'?
Thank you!
Aucun commentaire:
Enregistrer un commentaire