Untitled

 avatar
unknown
plain_text
a year ago
729 B
4
Indexable
def ShowUserAppointments(userid):
    cursor.execute("""
        SELECT a.appointmentid, d.firstname, d.lastname, a.bookingdate, a.bookinghour
        FROM allappointments a
        INNER JOIN doctors d ON a.doctorid = d.id
        WHERE a.userid = %s""", (user_id,))

    appointments = cursor.fetchall()

    if not appointments:
        print("No appointments found for this user.")
    else:
        table = PrettyTable()
        table.fieldnames = ["Appointment ID", "Doctor", "Date", "Hour"]

        for appointment in appointments:
            table.add_row([appointment[0], appointment[1] + ' ' + appointment[2], appointment[3], appointment[4]])
        print("Your Appointments:")
        print(table)
Editor is loading...
Leave a Comment