Skip to content
Advertisement

PHP If/Else Statements Not Hitting All Cases

I have this as my syntax, and my issue is that if both $employee and $saleDate are set the where clause is added as expected. However, if only $employee OR $saleDate are set, then the where clause is never added to the query.

What is the proper way to write this syntax so that the appropriate where clauses is added based off the user selection?

JavaScript

EDIT
My syntax here is working, except for where employee = ALL it is somehow missing that (or ignoring that since I thought I accounted for that)

JavaScript

Advertisement

Answer

The whole script can be simplified into the following one:

JavaScript

BUT, please note that your query is prone to SQL injection, so you better use prepared statements.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement