Title: Saving a multiple select in database
Last modified: August 30, 2016

---

# Saving a multiple select in database

 *  [nam_webdev](https://wordpress.org/support/users/nam_webdev/)
 * (@nam_webdev)
 * [10 years, 7 months ago](https://wordpress.org/support/topic/saving-a-multiple-select-in-database/)
 * I’m trying to save a multiple select of categories in the database for a plugin.
   
   I’m using this Code to display the multiple select:
 *     ```
       $categories_list = wp_dropdown_categories( array( 'echo' => 0 ) );
        $categories_list = str_replace( "name='cat' id=", "name='optionName[]' multiple='multiple' style=\"width:100%\" id=", $categories_list );
        echo $categories_list;
       ```
   
 * And this code for saving
 *     ```
       $nabanner_placement_CONTENT_ROLLOVER_new = sanitize_text_field( $_POST['nabanner_placement_CONTENT_ROLLOVER'] );
       if (preg_match('/(.*)/', $nabanner_placement_CONTENT_ROLLOVER_new)) {
       update_option('nabanner_placement_CONTENT_ROLLOVER', $nabanner_placement_CONTENT_ROLLOVER_new);}
       ```
   
 * But instead of saving the selected values to the database it just saves the string“
   Array”.

The topic ‘Saving a multiple select in database’ is closed to new replies.

## Tags

 * [array](https://wordpress.org/support/topic-tag/array/)
 * [database](https://wordpress.org/support/topic-tag/database/)
 * [Saving](https://wordpress.org/support/topic-tag/saving/)
 * [select](https://wordpress.org/support/topic-tag/select/)

 * 0 replies
 * 1 participant
 * Last reply from: [nam_webdev](https://wordpress.org/support/users/nam_webdev/)
 * Last activity: [10 years, 7 months ago](https://wordpress.org/support/topic/saving-a-multiple-select-in-database/)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
