title: HTML Select Form Keep Drop Down Values PHP
body: <p>Say I have a form that contains a drop-down list populated by values stored in my database:</p>
  
  <pre><code>&lt;form action="" method="POST"&gt;
      &lt;select name="item_select"&gt;
      &lt;?php 
      $query = "SELECT * FROM my_table ORDER BY name";
      $result = mysql_query($query);
      while ($row = mysql_fetch_object($result)) { 
      ?&gt;
          &lt;option value=&lt;?php echo $row-&gt;id; ?&gt; &gt; &lt;?php echo $row-&gt;name; ?&gt;&lt;/option&gt;
          &lt;?php }// end while?&gt;
      &lt;/select&gt;
      &lt;br /&gt;&lt;br /&gt;
      &lt;input name="action_1" type="submit" value="Action 1" /&gt;
      &lt;input name="action_2" type="submit" value="Action 2" /&gt;
  &lt;/form&gt; 
  </code></pre>
  
  <p>This all works fine, but I have a minor aesthetic issue I'd like to see if I can fix. Specifically every time I submit the form, the drop-down list selects the first item in the list, no matter which one I select. For instance.</p>
  
  <pre><code>List:
  Item1 (selected)
  Item2
  </code></pre>
  
  <p>I selected Item2 and submit the form, after the page submits it is still</p>
  
  <pre><code>List:
  Item1 (selected)
  Item2
  </code></pre>
  
  <p>Is there a way to have the drop-down "remember" which item was selected? For instance the desired effect after submitting the form for Item2 should be.</p>
  
  <pre><code>List:
  Item1
  Item2 (selected)
  </code></pre>