wordpress - 无法复选框值DB

时间:2015-08-04 11:40:05

标签: php wordpress checkbox

我的应用程序中有多个基于wordpress的复选框。我试图将复选框值保存到db,但值未保存。以下是我的代码。我实际上想要将复选框值保存在数组中。

<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>

这是我试图执行的PHP代码

  //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);

我已经检查了这个并尝试解决但没有结果how to save multiple checkboxes value in wordpress 任何人都可以帮助我。

0 个答案:

没有答案