Skip to main content
edited tags
Link
fuxia
  • 107.1k
  • 38
  • 255
  • 459
Source Link

Save data from a checkbox to a wpdb array

I have several fruit checkboxes but when saving to the wpdb database it only saves the last one that it checks, variable $check receives vardump string (6) "banana" string (5) "apple"

In the database only appears apple should be banana, apple in that same field an array. Should not only save it the last marked

 foreach( $checkboxes as $check ) {
    var_dump( $check); 
}

 global $wpdb; 
 $wpdb->insert('data',array( 
      'fruit' => $check
    ));