0

Well, I'm not doing well this weekend! Still struggling on pset7, this time I can't even get anything at all from the db to display on an html file. I've cut it down to the simplest code I can (copying the syntax that's already provided when querying the database for the user_id just to try and get something to work and am trying to display it on a tester page just to see something (anything!!!) coming through and nothing is happening (all I get is the 'Results' heading so the html page is showing, just no data) - soooo frustrating...can anyone tell me why?!!!

My application.py code for this is:

@app.route("/")
@login_required
def index():

    #Query database 
    rows=db.execute("SELECT * FROM users where id = :id", id = session["user_id"])
    return render_template("index.html", name=rows[0]["username"])

And my html is (the li> is from when I was trying to get all the shares info so isn't necessary but it shouldn't cause a problem...!?):

{% extends "layout.html" %}

{% block title %}
   Index
{% endblock %}

{% block main %}
<h2>RESULTS:</h2>
<ul>
    <li><h2> {{ name }}</h2></li>
</ul>
{% endblock %}

Again, any help very gratefully received to stop me throwing the mac out of the window right now.....!

1

Sorted! I just realised I kept refreshing the redirect from 'buy' instead of going directly to 'index' - for some reason the redirect doesn't use the code in index - I'll sort that later but for now I can at least start on getting the right data in...!!!

| improve this answer | |

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .