Feb-09-2019, 06:06 PM
Hello, iam reposting my previous post more clear written this time:
This is the data that form user selection upon drop down menus:
@app.route( '/seek', methods=['GET', 'POST'] ) def seek(): pdata = '' name = request.args.get('name') month = request.args.get('month') year = request.args.get('year') try: if name and month.isdigit() and year.isdigit(): cur.execute( '''SELECT * FROM jobs WHERE clientID = (SELECT id FROM clients WHERE name = %s) and MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (name, month, year) ) if (not name) and month.isdigit() and year.isdigit(): cur.execute( '''SELECT * FROM jobs WHERE MONTH(lastvisit) = %s and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (month, year) ) if name and (not month) and year.isdigit(): cur.execute( '''SELECT * FROM jobs WHERE clientID = (SELECT id FROM clients WHERE name = %s) and YEAR(lastvisit) = %s ORDER BY lastvisit DESC''', (name, year) ) if (not name) and (not month) and year.isdigit(): cur.execute( '''SELECT * FROM jobs WHERE YEAR(lastvisit) = %s ORDER BY lastvisit ASC''', year )Although the first two if()s work properly the third and forth doesnt and i cannot seem to understand why.
This is the data that form user selection upon drop down menus:
name = month = year = '' # populate names, months, years names.append( '' ) names.sort() months = ( '', 'Ιανουάριος', 'Φεβρουάριος', 'Μάρτιος', 'Απρίλιος', 'Μάϊος', 'Ιούνιος', 'Ιούλιος', 'Αύγουστος', 'Σεπτέμβριος', 'Οκτώβριος', 'Νοέμβριος', 'Δεκέμβριος' ) years = ( '', 2010, 2011, 2012, 2013, 2014, 2015, 2016, 2017, 2018, 2019 ) pdata = pdata + ''' <br><h3><br><font color=red size=6> Επιλεκτική Αναζήτηση </font><br> <form methods="POST" enctype="multipart/form-data" action="%s"> <select name="name"><option> %s </option></select> <select name="month"> %s </select> <select name="year"><option> %s </option></select> <br> <input type="image" src="/static/img/play.gif" name="seek" value="<Αναζήτηση>"> </form> ''' % (url_for( 'seek' ), '</option><option>'.join( names ), ''.join( map( lambda args: '<option value="%s">%s</option>' % (args[0], args[1]), enumerate( months ) ) ), '</option><option>'.join( list( map( str, years ) ) ) )[python]Can you help me please? This is troubling me days now....