Τη Τετάρτη, 12 Ιουνίου 2013 1:43:21 π.μ. UTC+3, ο χρήστης MRAB έγραψε: > On 11/06/2013 21:20, Νικόλαος Κούρας wrote: > > > [code] > > > if not re.search( '=', name ) and not re.search( '=', month ) > > and not re.search( '=', year ): > > > cur.execute( '''SELECT * FROM works WHERE clientsID = > > (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and > > YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', (name, month, year) ) > > > elif not re.search( '=', month ) and not re.search( '=', year ): > > > cur.execute( '''SELECT * FROM works WHERE > > MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', > > (month, year) ) > > > elif not re.search( '=', year ): > > > cur.execute( '''SELECT * FROM works WHERE > > YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year ) > > > else: > > > print('''<h2>Πώς να γίνει αναζήτηση αφού δεν επέλεξες > > ούτε πελάτη ούτε μήνα ή τουλάχιστον το έτος?''') > > > print( '''<meta http-equiv="REFRESH" > > content="5;/cgi-bin/pelatologio.py">''' ) > > > sys.exit(0) > > > > > > data = cur.fetchall() > > > > > > hits = money = 0 > > > > > > for row in data: > > > hits += 1 > > > money = money + row[2] > > > > > > ...... > > > ...... > > > selects based on either name, month, year or all of them > > > [/code] > > > > > > > > > The above if structure works correctly *only* if the user sumbits by form: > > > > > > name, month, year > > > or > > > month, year > > > > > > If, he just enter a year in the form and sumbit then, i get no error, but > > no results displayed back. > > > > > > Any ideas as to why this might happen? > > > > > What are the values of 'name', 'month' and 'year' in each of the cases? > > Printing out ascii(name), ascii(month) and ascii(year), will be helpful. > > > > Then try stepping through those lines in your head.
i hav epribted all values of those variables and they are all correct. i just dont see why ti fails to enter the specific if case. is there a shorter and more clear way to write this? i didnt understood what Rick trie to told me. can you help me write it more easily? -- http://mail.python.org/mailman/listinfo/python-list