【发布时间】:2021-09-17 01:03:48
【问题描述】:
我使用 .py 代码在 html 中显示表格:
@flask.route('/users_table', methods=['GET', 'POST'])
def users_table():
cur = mysql.connection.cursor(MySQLdb.cursors.DictCursor)
cur.execute('SELECT * FROM `users` WHERE isadmin = 0')
all_users = cur.fetchall()
return render_template('users-table.html', all_users=all_users
和.html代码:
<table class="table table-bordered" id="dataTable" width="100%" cellspacing="0">
<thead>
<tr>
<th>User Name</th>
<th>Email</th>
<th>Company</th>
<th>Status</th>
<th>Tools</th>
</tr>
</thead>
{% for row in all_users %}
<tr>
<td>{{row.username}}</td>
<td>{{row.email}}</td>
<td>{{row.company_name}}</td>
<td>{{row.isenabled}}</td>
<td><a href="/reset_user_pass/{{row.Id}}" data-toggle="modal" data-
target="#modaledit{{row.Id}}"><i class="fa fa-play"></i></a></td>
</tr>
{% endfor %}
</table>
我想根据 'status' 列的值更改 'fa fa-play' 图标。
我怎样才能做到这一点
【问题讨论】:
-
你想要哪个图标代表哪个状态?
标签: python mysql python-3.x flask