I'm have a little application I'm building... and there will be a search attached. I'm doing this a tiny bit at a time and then will build on it. 🙂
So far I have index.php, where the person enters the search criteria within a form. The form submit button switches to another php page and passes all the form names as variables.
I have a little SQL statement I'm building based on the form on the first page, using the variable names as the form field names.
So far I'm only searching on two fields. They are both drop-down menus. The first selection on both dropdowns will be blank, and if blank is selected, all results will display. The SQL works if the fields are valid, but how would I allow a blank to display all entries? I'm not sure how to build one SQL statement for if there are values, and if there are not.
I've tried putting in form field values of "" for blank, or a bogus value that I can reset on the search page itself, and use a LIKE in the SQL statement... but if I use a LIKE and a blank or null value, I get an error. 🙁 Is there a way to set the value to a wildcard, so it'll retreive all fields in the DB? I tried the %, but it didn't seem to work either. :p
$sqlsearch="select * from ETECHLOG where ((convert(float,ENTERED_BY) = $user) AND (SYSTEM = '$system'))";
How can I modify this statement....
Thanks.