title: set multiple select list options to selected from query
body: <p>I have a field named 'majors' which contains a string of integers seperated by commas.  This field is populated from a multiple select list on insert query using the following variable:</p>
  
  <pre><code>$majors_string = implode(",", $majors);
  </code></pre>
  
  <p>Now on the edit page, I want to have those values set the options in the same list.  Part of the problem is that the list is generated dynamically using:</p>
  
  <pre><code>&lt;select name="majors[]" size="9" multiple="multiple" id="majors"&gt;
            &lt;?php 
  $query = mysql_query("SELECT * from major ORDER BY title ASC");
  for($i=0;$i&lt;mysql_num_rows($query);$i++) {
  $row=mysql_fetch_assoc($query);
  ?&gt;
            &lt;option value="&lt;?php echo $row['major_pk']; ?&gt;"&gt;&lt;?php echo $row['title']; ?&gt;&lt;/option&gt;
            &lt;?php 
  }
  ?&gt;
          &lt;/select&gt;
  </code></pre>
  
  <p>On the initial query on the edit page, I have:</p>
  
  <pre><code>$query_topic = "SELECT * FROM topic WHERE topic_pk = '$topic_pk'";
  $result_topic = mysql_query($query_topic, $connection) or die(mysql_error());
  $row_topic = mysql_fetch_assoc($result_topic);
  
  $retrieved_majors = explode(",", $row_topic['majors']);
  </code></pre>
  
  <p>But I'm unsure as to set the options in the multiple list to the values in array $retrieved_majors.  </p>
  
  <p>Thanks for any help!</p>