Я хотел бы иметь возможность фильтровать таблицу на этой html-странице по кнопке, т.е. домену. Проверьте здесь Просмотр HTML . Например, если кто-то нажимает на фотографа, появляются только фотографы.
Функция колбы:
@app.route('/find_artist',methods=['POST', 'GET'])
def find_artist():
if session.get("email"):
if request.method == 'GET':
return render_template('find_artist.html')
curl = mysql.connection.cursor()
curl.execute("SELECT * FROM freelancers")
data = curl.fetchall()
curl.close()
return render_template(
"find_artist.html",
freelancers=data)
else:
return redirect(url_for('login'))
HTML-код для кнопок и таблицы:
<div id="myBtnContainer">
<button class="btn active" > Show all</button>
<button class="btn" > Illustrator</button>
<button class="btn"> Animator</button>
<button class="btn" > Digital Designer</button>
<button class="btn">Photographer</button>
<button class="btn"> Filmmaker</button>
<button class="btn"> Graphic Design</button>
</div>
<thead>
<tr>
<th scope="col">Serial</th>
<th scope="col">First Name </th>
<th scope="col">Last Name</th>
<th scope="col">Email</th>
<th scope="col">Domain</th>
<th scope="col">Experience</th>
</tr>
</thead>
<tbody id="myTable">
{% for item in freelancers %}
<tr>
<td>{{item["id"]}}</td>
<td>{{item["first_name"]}}</td>
<td>{{item["last_name"]}}</td>
<td>{{item["email"]}}</td>
<td>{{item["domain"]}}</td>
<td>{{item["experience"]}}</td>
</tr>
{% endfor %}
Спасибо:)