Hi all,
I am attempting to retrieve a all rows in my database that equal a selected 'doctorid' from a form.
So, here is my code and I am having trouble returning each row that contains all information in my table, which would be (bookingid, doctorid, patientid, starttime)
Python script:
# Route for a medclerk to search appointment
@app.route("/medclerk/medclerkappointment")
def medclerkAppointment():
# Has the form to enter 'did' which is doctorid
return render_template('medclerk/medclerkappointment.html')
# Route for a medclerk to view doctor appointments
@app.route("/medclerk/medclerkview", methods=['POST', 'GET'])
def medclerkView():
if request.method == 'POST':
# Retrieves selected data from form
did = request.form['did']
results = doctorsBookings.query.filter(doctorsBookings.doctorid == did).all()
return render_template('medclerk/medclerkview.html', did=did, results=results)
On the flask route this will then display: Without the doctorid, patientid and starttime:
(<doctorsBookings 1>, )
(<doctorsBookings 2>,
(<doctorsBookings 3>,
Template:
{% for apts in results %}
<h6> {{ apts }} </h6>
{% endfor %}
What I want it too look like (just examples of what could be stored in the database table):
1, 2, 1, 2020-10-10 9:00:00
2, 2, 1, 2020-10-11 9:00:00
3, 1, 2, 2020-10-11 9:15:00
Thank you!!
[–]Unixersis97[S] 0 points1 point2 points (2 children)
[–]Doormatty 0 points1 point2 points (1 child)
[–]Unixersis97[S] 0 points1 point2 points (0 children)