This works, coming from a form to post.
$select_make = $_POST['select_make'];
$select_model = $_POST['select_model'];
$select_year = $_POST['select_year'];
$select_city = $_POST['select_city'];
$select_state = $_POST['select_state'];
$select_zip = $_POST['select_zip'];
$MAKE = implode("','",$_POST['MAKE']);
$MODEL = implode("','",$_POST['MODEL']);
$YEAR = implode("','",$_POST['YEAR']);
$CITY = implode("','",$_POST['CITY']);
$STATE = implode("','",$_POST['STATE']);
$ZIP = implode("','",$_POST['ZIP']);
$query = "UPDATE $catagory$subcatagory SET ACTIVE='1' WHERE CLOSEDATE > '$date'";
if($select_make =='1'){
$query.=" AND MAKE IN ('".$MAKE."')";
}
if($select_model =='1'){
$query.=" AND MODEL IN ('".$MODEL."')";
}
if($select_year =='1'){
$query.=" AND YEAR IN ('".$YEAR."')";
}
if($select_city =='1'){
$query.=" AND CITY IN ('".$CITY."')";
}
if($select_state =='1'){
$query.=" AND STATE IN ('".$STATE."')";
}
if($select_zip =='1'){
$query.=" AND ZIP IN ('".$ZIP."')";
}
$result = mysql_query($query) or die(mysql_error());
print $query;
And this is what I am trying to get working, I am pulling the data from a database.
$selectmake = $row["select_make"];
$selectmodel = $row["select_model"];
$selectyear = $row["select_year"];
$selectcity = $row["select_city"];
$selectstate = $row["select_state"];
$selectzip = $row["select_zip"];
$selectedmake = $row["selected_make"];
$selectedmodel = $row["selected_model"];
$selectedyear = $row["selected_year"];
$selectedcity = $row["selected_city"];
$selectedstate = $row["selected_state"];
$selectedzip = $row["selected_zip"];
}
$selectedmakestr = "$selectedmake";
// Turn the - into ','
$selectedmakestr = str_replace("-", "','", $selectedmakestr);
// Remove the extra ', from the start, and ,' from the end
$selectedmakestr = "'".$selectedmakestr."'";
echo "$selectedmakestr <br>";
$selectedmodelstr = "$selectedmodel";
// Turn the - into ','
$selectedmodelstr = str_replace("-", "','", $selectedmodelstr);
// Remove the extra ', from the start, and ,' from the end
$selectedmodelstr = "'".$selectedmodelstr."'";
$selectedyearstr = "$selectedyear";
// Turn the - into ','
$selectedyearstr = str_replace("-", "','", $selectedyearstr);
// Remove the extra ', from the start, and ,' from the end
$selectedyearstr = "'".$selectedyearstr."'";
$selectedcitystr = "$selectedcity";
// Turn the - into ','
$selectedcitystr = str_replace("-", "','", $selectedcitystr);
// Remove the extra ', from the start, and ,' from the end
$selectedcitystr = "'".$selectedcitystr."'";
$selectedstatestr1 = "$selectedstate";
// Turn the - into ','
$selectedstatestr = str_replace("-", "','", $selectedstatestr);
// Remove the extra ', from the start, and ,' from the end
$selectedstatestr = "'".$selectedstatestr."'";
$selectedzipstr = "$selectedzip";
// Turn the - into ','
$selectedzipstr = str_replace("-", "','", $selectedzipstr);
// Remove the extra ', from the start, and ,' from the end
$selectedzipstr = "'".$selectedzipstr."'";
$query = "UPDATE LUTHERSELLANDRECOMMEND SET ACTIVE = '1' WHERE CLOSEDATE > '$date' ";
if($selectmake =='1'){
$query.=" AND MAKE IN (".$selectedmakestr.")";
}
if($selectmodel =='1'){
$query.=" AND MODEL IN (".$selectedmodelstr.")";
}
if($selectyear =='1'){
$query.=" AND YEAR IN (".$selectedyearstr.")";
}
if($selectcity =='1'){
$query.=" AND CITY IN (".$selectedcitystr.")";
}
if($selectstate =='1'){
$query.=" AND STATE IN (".$selectedstatestr.")";
}
if($selectzip =='1'){
$query.=" AND ZIP IN (".$selectedzipstr.")";
}
print $query;
Thanks for any ideas.