I try to add checked in my checkbox, if a value in checkbox is same with the value from database:
My database : Column = fees_month[] Value = '$row[month]'
My Default checkbox :
echo "<th >"."<input type='checkbox' name='fees_month[]' value= '$row[month]' checked='isChecked('$row[month]',$fees_month)' >". $row['month']."</th>";
$q = mysqli_query($conn,"SELECT * FROM fees WHERE registration_number='$qry[registration_number]'");
while ($info = mysqli_fetch_array($q)) {
$fees_month = explode(", ", $info['fees_month']);
}
function isChecked($val, $arr) {
if (in_array($val, $arr)) {
echo 'checked';
}
}