update association table with post array from checkboxes php/mysql
ok, I have a dynamic site so the checkboxes are added to the page dynamically from database. the name of checkboxes sets it to an array "checkbox[]". now my $_Post['checkbox'] will be an array. now I want to take that array and make a for loop that updates my table once for each variable in the array but it's not working and I'm stumped...
if ((isset($_POST["MM_update"])) && ($_POST["MM_update"] == "form1")) {
for ($i=0;$i<count($_POST['SpecificationEquipped']);$i++) {
$updateSQL = sprintf("UPDATE TestersSpecifications SET SpecificationEquipped=%s WHERE TesterModel=%s AND SpecificationID=%s",
GetSQLValueString(isset($_POST['SpecificationEquipped'][$i]) ? "true" : "", "defined","1","0"),
GetSQLValueString($_POST['TesterModel'], "text"),
GetSQLValueString($_POST['SpecificationID'][$i], "int"));
mysql_select_db($database_ampacin1_ampac, $ampacin1_ampac);
$Result1 = mysql_query($updateSQL, $ampacin1_ampac) or die(mysql_error());
}
}
I'm not sure how to make the array work the way the code is for "defined". anyone think they can tell me the best way to do this?
