Given Data in a varchar mysql field 1,3,6
I have 7 checkboxes for SUN MON TUE WED THU FRI SAT I have stored the days that need to be checked but I want to display all non checked and checked boxes
So for my example output will be SUN(checked) MON TUE(checked) WED THU FRI(checked) SAT These 7 words represent checkboxes. assumed the data is a varchar mysql field 1,3,6
My code works partially because it will only show the first day that needs to be checked but not the other ones. It does However display the non-checked checkboxes which is good.
Here is my code: BTW sorry if the formatting is weird! I am new here.
<? php
$RecurringDays = explode(",", $recur['weekday']);
for ($i = 1; $i <= count($RecurringDays) - 1; $i++) {
if ($RecurringDays[$i - 1] == "1") {
echo "<td><input type='checkbox' name='0' id='0' checked='checked' />";
echo "<label for='0'>Sun </label></td>";
continue;
} else {
echo "<td><input type='checkbox' name='0' id='0' />";
echo "<label for='0'>Sun </label></td>";
}
if ($RecurringDays[$i - 1] == "2") {
echo "<td><input type='checkbox' name='1' id='1' checked='checked' />";
echo "<label for='0'>Mon </label></td>";
continue;
} else {
echo "<td><input type='checkbox' name='1' id='1' />";
echo "<label for='0'>Mon </label></td>";
}
if ($RecurringDays[$i - 1] == "3") {
echo "<td><input type='checkbox' name='2' id='2' checked='checked' />";
echo "<label for='0'>Tue </label></td>";
continue;
} else {
echo "<td><input type='checkbox' name='2' id='2' />";
echo "<label for='0'>Tue </label></td>";
}
if ($RecurringDays[$i - 1] == "4") {
echo "<td><input type='checkbox' name='3' id='3' checked='checked' />";
echo "<label for='0'>Wed </label></td>";
continue;
} else {
echo "<td><input type='checkbox' name='3' id='3' />";
echo "<label for='0'>Wed </label></td>";
}