This seems simple but I cannot find a good answer anywhere. I am trying to pass several variables from a form, and some the user might decide do not pertain so they can leave blank, in which case no value is passed to the results page (such as name being left blank so the name value posted is ""
On the results page, I want to run a query that returns all results for a field that is left blank on the search form.
So if someone chooses NY for state and leaves name blank, I want my query to return all names for people in NY since they choose NY for State but left in the form but left Name blank.
I need a condition inside the where clause that inserts the selected name value if selected or else if was left blank on form returns all values for that variable that meet the AND criteria.
//Get variables from form page (and they left name blank/no value so name="")
$name = $_GET['name'];
$state = $_GET['state'];
$query = "
(SELECT *
FROM schools
where name= **HOW GET ALL RESULTS IF VALUE
WAS BLANK OR ELSE USE THE SELECTED VALUE IF SELECTED?**
and city='$city')";