Update Not Working Correctly
For some reason if I uncheck a checkbox, it won't save that it is now unchecked. But, if there is a checkbox group, it will remember that it is unchecked as long as there is one checked. Here is my code:
<?php
if (isset($_POST["submit"]) || isset($_POST["submit_x"])) {
$UpdateQuery = new WA_MySQLi_Query($sdpc_i);
$UpdateQuery->Action = "update";
$UpdateQuery->Table = "`data`";
$UpdateQuery->bindColumn("districtID", "i", "".((isset($_POST["districtID"]))?$_POST["districtID"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("softwareID", "i", "".((isset($_POST["softwareID"]))?$_POST["softwareID"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("agreement_typesID", "i", "".((isset($_POST["agreement_typesID"]))?$_POST["agreement_typesID"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("agreement_file", "s", "".(((isset($_FILES["agreement_file"]))? preg_replace('/.[^.]*$/', '', $_FILES["agreement_file"]["name"]) :"")) ."", "WA_IGNORE");
$UpdateQuery->bindColumn("signed_agreement_file", "s", "".(((isset($_FILES["signed_agreement_file"]))? preg_replace('/.[^.]*$/', '', $_FILES["signed_agreement_file"]["name"]) :"")) ."", "WA_IGNORE");
$UpdateQuery->bindColumn("statusID", "i", "".((isset($_POST["statusID"]))?$_POST["statusID"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("date_approved", "t", "".((isset($_POST["date_approved"]))?$_POST["date_approved"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("date_expired", "t", "".((isset($_POST["date_expired"]))?$_POST["date_expired"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("requestor", "s", "".((isset($_POST["requestor"]))?$_POST["requestor"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("requestor_email", "s", "".((isset($_POST["requestor_email"]))?$_POST["requestor_email"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("school", "s", "".((isset($_POST["school"]))?implode(", ",$_POST["school"]):"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("year", "s", "".((isset($_POST["year"]))?$_POST["year"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("grade_level", "s", "".((isset($_POST["grade_level"]))?implode(", ",$_POST["grade_level"]):"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("content_area", "s", "".((isset($_POST["content_area"]))?implode(", ",$_POST["content_area"]):"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("cost", "s", "".((isset($_POST["cost"]))?$_POST["cost"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("paid_by", "s", "".((isset($_POST["paid_by"]))?$_POST["paid_by"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("media_release", "s", "".((isset($_POST["media_release"]))?$_POST["media_release"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("declined_reasoning", "s", "".((isset($_POST["declined_reasoning"]))?$_POST["declined_reasoning"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("notes", "s", "".((isset($_POST["notes"]))?$_POST["notes"]:"") ."", "WA_IGNORE");
$UpdateQuery->bindColumn("request_submitted_date", "t", "".((isset($_POST["request_submitted_date"]))?$_POST["request_submitted_date"]:"") ."", "WA_IGNORE");
$UpdateQuery->addFilter("dataID", "=", "i", "".($_GET['dataID']) ."");
$UpdateQuery->execute();
$UpdateGoTo = "manage_agreements.php?state=" . $_GET['state'] . "&districtID=" . $_GET['districtID'] . "";
if (function_exists("rel2abs")) $UpdateGoTo = $UpdateGoTo?rel2abs($UpdateGoTo,dirname(__FILE__)):"";
$UpdateQuery->redirect($UpdateGoTo);
}
?>
Checkbox code looks like this:
<input <?php if (!(strcmp($district_data->getColumnVal("media_release"),"Yes"))) {echo "checked=\"checked\"";} ?> name="media_release" type="checkbox" value="Yes" aria-label="Requires Media Release">
Thanks