I'm new in php programming. I have one question here. Currently i have 12 checkbox created using array implode. when i check for example, one checkbox, the data will save in database but when i uncheck all the checkbox(no single checkbox was checked), there is an error occur. below is the error:
Notice: Undefined index: transportMode in C:\xampp\htdocs\tggd\page\patient-health-care\edit-patient-health_2.php on line 11
Warning: implode(): Invalid arguments passed in C:\xampp\htdocs\tggd\page\patient-health-care\edit-patient-health_2.php on line 11
below is the current code:
edit-patient-health2.php
<?php
$checked_arr = array();
$checked_arr = explode(",",$transportMode);
$transportMode = array("Transported","Transport Refused/declines","Decrease on examination","Operational Standby","Sporting/special event standby","Unable to locate patient","Assist another ambulance","Transport retrieval team","SIDS","S/D Assault","Single journey","Return journey","Escort police","Nurse","MO");
foreach($transportMode as $transportMode1){
$checked = "";
if(in_array($transportMode1,$checked_arr)){
$checked = "checked";
}
echo
'<input type="checkbox" name="transportMode[]" class="form-check-input; larger" style="margin-right: 20px; margin-left: 50px;" value="'.$transportMode1.'" '.$checked.'> '.$transportMode1.' <br/>';
}
?>
edit-patient-health_2.php
$transportMode=implode(",",$_POST["transportMode"]); //line 11
can someone help me? thank you