this works:
if ( strtolower($make)=="toyota" && ( strpos(strtolower($model), "scion") !== false || strpos(strtolower($model), "scoin") !== false || strtolower($model) == "xa" || strtolower($model) == "xb" || strtolower($model) == "tc" || strtolower($model) == "xd" || strtolower($model) == "iq" || strtolower($model) == "fr-s" || strtolower($model) == "ia" || strtolower($model) == "im" ) ){
//turn make into scion
$make = "scion";
}
this doesn't work
$db_scion_models = "";
$scion_models_result = mysqli_query($conn,"SELECT DISTINCT vehicle_model_name FROM mod_vehicle_models WHERE mod_vehicle_make_id = '41' "); //41=scion
while ($scion_model_row = mysqli_fetch_assoc($scion_models_result)) {
$db_scion_models .= '|| strtolower($model) == "'.$scion_model_row['vehicle_model_name'].'" ';
}
if (!empty($db_scion_models)) {
$db_scion_models = 'strpos(strtolower($model), "scion") !== false || strpos(strtolower($model), "scoin") !== false '.$db_scion_models;
} else {
$db_scion_models = 'strpos(strtolower($model), "scion") !== false || strpos(strtolower($model), "scoin") !== false';
}
if ( strtolower($make)=="toyota" && ( $db_scion_models ) ){
//turn make into scion
$make = "scion";
}
if statement has variable to try and make it dynamic. the following happens:
these convert to scion properly: toyota FR-S toyota iA toyota iM toyota tC these convert to scion but shouldn't: toyota 4runner toyota avalon toyota camry toyota corolla toyota highlander toyota prius
if statement is spelled out in a static way. the following happens:
these convert to scion properly: toyota FR-S toyota iA toyota iM toyota tC these don't convert to scion: toyota 4runner toyota avalon toyota camry toyota corolla toyota highlander toyota prius
I want dynamic and static way to work the same. What am i doing wrong?
Edit...
so do it like this?
$db_scion_models_array = array();
$scion_models_result = mysqli_query($conn,"SELECT DISTINCT vehicle_model_name FROM mod_vehicle_models WHERE mod_vehicle_make_id = '41' "); //41=scion
while ($scion_model_row = mysqli_fetch_assoc($scion_models_result)) {
$db_scion_models_array[]=$scion_model_row['vehicle_model_name'];
}
if ( strtolower($make)=="toyota" && in_array(strtolower($model), $db_scion_models_array, true) ) {
//turn make into scion
$make = "scion";
}