title: Getting POST data from SELECT dropdown with variable value
body: <p>I need to create as many dropdowns as values from a database table query in worpress. I can't get post data to usermeta table from foreach dropdown list . This is the code:</p>
  
  <pre><code>$custom_posts_type = $wpdb-&gt;get_results("SELECT label,id FROM $table_name");
        foreach ($custom_posts_type as $custom_post_type) {
             $custom_post_type_name = $custom_post_type-&gt;label;
             $custom_post_type_id = $custom_post_type-&gt;id;
             ?&gt;
             &lt;p&gt;   
             &lt;label for="dropdown"&gt;Permisos de usuario para &lt;?php echo $custom_post_type_name;?&gt;: &lt;/label&gt;
             &lt;?php                                               
             $user_custom_post = 'user_custom_' . $custom_post_type_name;
             $selected = get_the_author_meta( $user_custom_post, $user-&gt;ID ); 
             $post_type_object = get_post_type_object($custom_post_type_name);                        
             $label = $post_type_object-&gt;label;
             $posts = get_posts(array('post_type'=&gt; $custom_post_type_name, 'post_status'=&gt; 'publish', 'suppress_filters' =&gt; false, 'posts_per_page'=&gt;-1));                        
             echo '&lt;select name="' . $user_custom_post . '" id="' . $user_custom_post . '"&gt;';                                               
              ?&gt;
              &lt;option value="all" &lt;?php selected( $user_custom_post[0], "all" ); ?&gt;&gt;All &lt;?php echo $label;?&gt;&lt;/option&gt;
              &lt;?php 
              foreach ($posts as $post) {
                  echo '&lt;option value="', $post-&gt;ID, '"', $selected == $post-&gt;ID ? ' selected="selected"' : '', '&gt;', $post-&gt;post_title, '&lt;/option&gt;';
               }?&gt;            
             &lt;?php
             echo '&lt;/select&gt;';
             ?&gt;                        
             &lt;/p&gt;
            &lt;?php
            update_user_meta( $user-&gt;ID, $user_custom_post, $_POST[$user_custom_post] );                        
   } //endforeach
  </code></pre>
  
  <p>I appreciate your help.
  Thks</p>