title: Multiple select field - use selected="selected" multiple times
body: <p>I have a multiple field like this:</p>
  
  <pre><code>&lt;select name="excluded_groups[]"&gt;
      &lt;?php echo $foo-&gt;multi_group_select_options($group_ids, $excluded_id); ?&gt;
  &lt;/select&gt;
  </code></pre>
  
  <p>I manage to get results from the database via this function and put them in the <code>&lt;select&gt;</code>, but I can't manage to keep the selected values selected.</p>
  
  <p>The first parameter should add <code>selected="selected"</code> to the field that were marked before submission and then got submitted, the second parameter prevents a group_id to be displayed (2nd parameter works as it should).</p>
  
  <p>Here is the function...</p>
  
  <pre><code>/**
  * group_options
  * Get group names in the dropdown list
  */
  public function multi_group_select_options($default = false, $exclude_id = '')
  {
      global $user;
  
      $exclude_id = (isset($this-&gt;config['default_group'])) ? $this-&gt;config['default_group'] : 5;
  
      $sql_where = ($user-&gt;data['user_type'] == USER_FOUNDER) ? '' : 'WHERE group_founder_manage = 0';
      $sql_where_and = (!empty($sql_where)) ? ", AND group_id &lt;&gt; $exclude_id" : "WHERE group_id &lt;&gt; $exclude_id";
      $sql = 'SELECT group_id, group_name, group_type
              FROM ' . GROUPS_TABLE . "
              $sql_where
              $sql_where_and
              ORDER BY group_name";
      $result = mysql_query($sql);
  
      $s_group_options = '';
      while ($row = mysql_fetch_assoc($result))
      {
          /*if (is_array($default))
          {
              break;
              $group_id = '';
              foreach ($default as $key =&gt; $group_id)
              {
                  $group_id = $group_id;  
              }
          }
  
          print_r($default);*/
  
          $selected = ($row['group_id'] == $group_id) ? ' selected="selected"' : '';
          $s_group_name = ($row['group_type'] == GROUP_SPECIAL) ? $user-&gt;lang['G_' . $row['group_name']] : $row['group_name'];
          $s_group_options .= '&lt;option'  . (($row['group_type'] == GROUP_SPECIAL) ? ' class="sep"' : '') . ' value="' . $row['group_id'] . '"' . $selected . '&gt;' . $s_group_name . '&lt;/option&gt;';
      }
      $db-&gt;sql_freeresult($result);
  
      return $s_group_options;
  }
  </code></pre>
  
  <p>The array I am putting as a first parameter is totally valid. It's just a normal array with keys and values, where the values are the group ids.</p>
  
  <p>Tried using foreach inside the while - didn't work, same with outside the while loop.</p>
  
  <p>The $default array looks like this:</p>
  
  <pre><code>Array
  (
      [0] =&gt; 1
      [1] =&gt; 7
      [2] =&gt; 2
      [3] =&gt; 3
  )
  </code></pre>