Jun-21-2020, 12:38 AM
(This post was last modified: Jun-21-2020, 12:39 AM by card51shor.)
OK so I finally started coding it a bit. I immediately have the same issue I was talking about.
I can't run another query since there is no click event like the search button to start the search from being run.
Basically what I'm saying is how can I get the result list from clicking the search button into my book function?
I don't think I can do it the way you said - at least not any way I'm aware of. Can you help me out a bit?
Thanks
Here's my code. Obviously the "result" variable is not usable in my book function. How can I change that?
I can't run another query since there is no click event like the search button to start the search from being run.
Basically what I'm saying is how can I get the result list from clicking the search button into my book function?
I don't think I can do it the way you said - at least not any way I'm aware of. Can you help me out a bit?
Thanks
Here's my code. Obviously the "result" variable is not usable in my book function. How can I change that?
@app.route("/search", methods=["GET", "POST"]) def search(): search = request.form.get("search") searchCombo = search + '%' result = db.execute("SELECT * FROM books WHERE author LIKE :search OR isbn LIKE :search OR title LIKE :search LIMIT 20", {'search': searchCombo}).fetchall() return render_template("search.html", search=result) @app.route("/book", methods=["GET", "POST"]) def book(): return render_template("book.html")HTML:
<!DOCTYPE html> <html> <head> <title>{{isbnResult}}</title> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <link href="static/bootstrap.min.css" rel="stylesheet" media="screen"> </head> <body> <p>ISBN: {{result[0]}}</p> <p>Title: {{result[1]}}</p> <p>Author: {{result[2]}}</p> <p>Year: {{result[3]}}</p> <p>Reviews: </p> </body> </html>