I have checkboxes (one for each day of the week) that I want to mark checked if the value is in an array. The value of $row['specialDaily'] could be something like 1,2,0 or 1 or 2,3,6 etc.
<?php $weekdays = array($row['specialDaily']);?>
<input name="monday" type="checkbox" id="monday" value="1" class="weekday" <?php if (in_array("1", $weekdays)) {
echo "checked='checked'";
}?> /><input name="tuesday" type="checkbox" id="tuesday" value="2" class="weekday" <?php if (in_array("2", $weekdays)) {
echo "checked='checked'";
}?> />
If the array only contains one value, the proper checkbox is checked. However, if it contains more than 1 value no checkboxes are checked. I just found the in_array() function and assumed it was exactly what I'm looking for. I assumed that since $row['specialDaily']'s value is like an array I could just plug it in. Unfortunately, (unless I'm missing something simple) I'm thinking it doesn't work the way I hoped.
Thanks in advance,
Twitch