html :
<body>
<h1>Restaraunts in Kannur </h1>
<table id="table1">
<thead>
<th>Restaraunt name</th>
<th>Opening time</th>
<th>Veg / Non-veg</th>
<th>Parking?</th>
</thead>
<tbody>
{% for i in sqldata %}
<tr>
<td>{{i[0]}}</td>
<td>{{i[1]}}</td>
<td>{{i[2]}}</td>
<td>{{i[3]}}</td>
<td>{{i[4]}}</td>
<td>{{i[5]}}</td>
<td>{{i[6]}}</td>
<td>{{i[7]}}</td>
<td>{{i[8]}}</td>
<td>{{i[9]}}</td>
</tr>
{% endfor %}
</tbody>
</table>
python :
import mysql.connector
mydb = mysql.connector.connect(host='localhost',user='amarnath',password='#@Marnath3',database='project')
from flask import Flask,render_template,request
mycursor=mydb.cursor()
app = Flask(__name__)
@app.route('/')
def home():
return render_template('Home.html')
@app.route("/kannur")
def kollam():
query='SELECT*FROM kannur'
mycursor.execute(query)
data=mycursor.fetchall()
return render_template('/kannur.html',sqldata=data)
I currently have code that displays a table in html using python flask and mysql. how do i add a filter button that executes a new query with ‘WHERE’ condition on the same table
New contributor
Amarnath Vm is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.