I'm new to programming and even newer to Python and would be grateful for some help on what has been a tough problem for me. The project I am working on is an electronic medical record using MySQL/Python. I'm currrently working on a module that looks up a patient's name based on input from the user.
My goal is a lookup based on the first 2 or 3 letters of the patient's last name. The matching results would appear as numbered choices so that the user would choose only a number to then access various parts of the patient's record. The results might look like this for user input "smi": 1 387 John Smith 2 453 Jane Smith 3 975 Joe Smithton Here is a copy of what I have so far, name_lookup.py: import MySQLdb def name_find(namefrag): conn = MySQLdb.connect(host = "localhost", user = "root", passwd = "n85", db = "meds") cursor = conn.cursor(MySQLdb.cursors.DictCursor) cursor.execute("SELECT patient_ID, firstname, lastname FROM demographics WHERE lastname LIKE '"+ str(namefrag)+"%'") results = cursor.fetchall() for row in results: print "%s %s %s %s" % (row["patient_ID"], row["firstname"], row["lastname"]) cursor.close() conn.close() Thanks in advance for any help. Mike -- http://mail.python.org/mailman/listinfo/python-list