Basically what I'm doing it creating a form and if a value is set it needs to add the proper MySQL syntax to query it.
$q_states = array($q_AL, $q_AK, $q_AZ, $q_AR, $q_CA, $q_CO, $q_CT, $q_DE, $q_FL, $q_GA, $q_HI, $q_ID, $q_IL, $q_IN, $q_IA, $q_KS, $q_KY, $q_LA, $q_ME, $q_MD, $q_MA, $q_MI, $q_MN, $q_MS, $q_MO, $q_MT, $q_NE, $q_NV, $q_NH, $q_NJ, $q_NM, $q_NY, $q_NC, $q_ND, $q_OH, $q_OK, $q_OR, $q_PA, $q_RI, $q_SC, $q_SD, $q_TN, $q_TX, $q_UT, $q_VT, $q_VA, $q_WA, $q_DC, $q_WV, $q_WI, $q_WY);
foreach ($q_states as $value) {
if ($value != "") {
$states = " state_name='".$value."'";
}
}
What I need to do is be able to get $state to equal nothing when there's no state value,
$states = " ";
Just one state selected:
$states = " AND (state_name='.$states.') ";
more than 1 state selected:
$states = " AND (state_name='.$states.' OR state_name='.$states.' OR state_name='.$states.') ";