Hello,
I have a php checkboxes that contain days of the week:
[ ] Sun [ ] Mon [ ] Tue etc....
In my database I have a field that seperates the days with commas like this:
0,1,0,0,0,1,0
Basically, it is like binary code. 0 means that Sun is NOT checked.....1 means that Monday IS checked.
I want to give the end user the ability to check days on or off. How can I setup the array to replace the data?
For example;
Lets say I have the following days checked....
0,1,0,0,0,1,0
but the user decides to UNCHECK monday....
0,0,0,0,0,1,0
how should I setup the form and query to update the change?
I am using the following array scheme to pre-fill the checkboxes.
if ( $_POST[days] [0] == 'Sun' ) {
$checked0 = "checked";
} else {
$checked0 = "";
}
if ( $_POST[days][1] == 'Mon' ) {
$checked1 = "checked";
} else {
$checked1 = "";
}
if ( $_POST[days][2] == 'Tue' ) {
$checked2 = "checked";
} else {
$checked2 = "";
}
if ( $_POST[days][3] == 'Wed' ) {
$checked3 = "checked";
} else {
$checked3 = "";
}
if ( $_POST[days][4] == 'Thu' ) {
$checked4 = "checked";
} else {
$checked4 = "";
}
if ( $_POST[days][5] == 'Fri' ) {
$checked5 = "checked";
} else {
$checked5 = "";
}
if ( $_POST[days][6] == 'Sat' ) {
$checked6 = "checked";
} else {
$checked6 = "";
}