Answered step by step
Verified Expert Solution
Question
1 Approved Answer
I am making a python flask trivia website. The following code is for the leaderboard. It is supposed to put it in descending order by
I am making a python flask trivia website. The following code is for the leaderboard. It is supposed to put it in descending order by score but it isn't working for some reason. How do I fix this?
Python Flask:
@app.route("/leaderboard") def leaderboard(): con = sqlite3.connect("scores.db") con.row_factory = sqlite3.Row cur = con.cursor() cur.execute("SELECT username, password, score, index1, answer, message FROM scores ORDER BY score DESC"); con.commit() cur.execute("select username,score from scores"); con.commit() rows = cur.fetchall(); return render_template("leaderboard.html",rows = rows)
HTML:
{% extends "layout.html" %} {% block content %} div class="leaderboard"> body> table border = 1> thead> td>Usernametd> td>Scoretdthead> {% for row in rows %} tr> td>{{row["username"]}}td> td>{{row["score"]}}td> tr> {% endfor %} table> body> div> {% endblock %}Username Score John Larry 45 Jenn John Larry 45 Jenn testerl11 0 tester121 -600 145 75 145 75
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started