title: How to echo previously selected option in drop down first?
body: <p>I am using the follow bit below.  I am first querying the db to see all available options but this is for an edit form so i want the drop down to show the previously selected value so i did another query and got the selection.  When i do it the way i have it below it will keep repeating the previously selected selection after each available option.  HOw to fix this?</p>
  
  <pre><code>&lt;option&gt;Select Sales rep&lt;/option&gt;
  &lt;?php
  
  $query="select agent_id, agent_name from agent_names where agent_id='$ad' 
  order by agent_name asc";
  $result=mysql_query($query);
  while(list($agent_id, $agent_name)=mysql_fetch_row($result)) {
      echo "&lt;option value=\"".$previousname."\"&gt;".$previousselection."&lt;/option&gt;
      &lt;option value=\"".$agent_id."\"&gt;".$agent_name."&lt;/option&gt;";
  }
  
  
  ?&gt;
  </code></pre>
  
  <p></p>