I have multiple checkboxes in my application based on wordpress. I am trying to save the checkboxes values to db but the values are not getting saved. Below is my code. I actually wanted to save the checkboxesvalues in an array.
<input type="checkbox" id="sunday_check12" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check12" class="timeslot_input_label sunday_input_label">12</label>
<input type="checkbox" id="sunday_check13" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check13" class="timeslot_input_label sunday_input_label">13</label>
<input type="checkbox" id="sunday_check14" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check14" class="timeslot_input_label sunday_input_label">14</label>
<input type="checkbox" id="sunday_check15" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check15" class="timeslot_input_label sunday_input_label">15</label>
<input type="checkbox" id="sunday_check16" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check16" class="timeslot_input_label sunday_input_label">16</label>
<input type="checkbox" id="sunday_check17" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check17" class="timeslot_input_label sunday_input_label">17</label>
<input type="checkbox" id="sunday_check18" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check18" class="timeslot_input_label sunday_input_label">18</label>
<input type="checkbox" id="sunday_check19" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check19" class="timeslot_input_label sunday_input_label">19</label>
<input type="checkbox" id="sunday_check20" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check20" class="timeslot_input_label sunday_input_label">20</label>
<input type="checkbox" id="sunday_check21" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check21" class="timeslot_input_label sunday_input_label">21</label>
<input type="checkbox" id="sunday_check22" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check22" class="timeslot_input_label sunday_input_label">22</label>
<input type="checkbox" id="sunday_check23" name="sunday_input[]" class="timeslot_input sunday_input" value="1">
<label for="sunday_check23" class="timeslot_input_label sunday_input_label">23</label>
and here is the PHP code I am trying to execute
//submit code
if(isset($_POST['sunday_input']) ){
$data=serialize($_POST['sunday_input']);
}
$user_id = '1';
global $wpdb;
$tablename_timeslots = $wpdb->prefix.'timeslots';
$timeslot_data = array(
'user_id' => $user_id,
'sunday_check' => $data
);
$wpdb->insert($tablename_timeslots, $timeslot_data, $format);
I have checked this and tried to work out but no result how to save multiple checkboxes value in wordpress
Can anyone please help me in this.