title: PHP keep dropdown value after submit
body: <p>I have the following code for a simple calculator. The code works fine, but I want the value in the dropdown list to stay there after submitted. How would I do this? 
  Essentially, I want the operator to stay selected once the calculation has been done. At the moment, it just shows a '+', even if the sum is 25 / 5.</p>
  
  <pre><code>&lt;?php 
  
  $number1 = $_POST['number1'];
  $number2 = $_POST['number2'];
  $operation = $_POST['operator'];
  
  
  Switch ($operation) {
  case 'add': $answer = $number1 + $number2;
  break;
  case 'minus': $answer = $number1 - $number2; 
  break;
  case 'divide': $answer = $number1 / $number2; 
  break;
  case 'multiply': $answer = $number1 * $number2;
  break;
  }
  
  
  ?&gt;
  
  &lt;form name='calculator' method='post' action=''&gt;
  &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;
              &lt;input name="number1" type="text" value="&lt;?php     i    if(isset($_POST['number1'])) { echo  htmlentities($_POST['number1']);}?&gt;"         /&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;select name="operator"&gt;
                  &lt;option value="add"&gt;+&lt;/option&gt;
                  &lt;option value="minus"&gt;-&lt;/option&gt;
                  &lt;option value="divide"&gt;/&lt;/option&gt;
                  &lt;option value="multiply"&gt;x&lt;/option&gt;
              &lt;/select&gt;
          &lt;/td&gt;
          &lt;td&gt;
              &lt;input name="number2" type="text" value="&lt;?php     if(isset($_POST['number2'])) { echo  htmlentities($_POST['number2']);}?&gt;"     /&gt;
          &lt;/td&gt;
          &lt;td&gt;    
              &lt;input name="submit" type="submit" value="=" /&gt;
          &lt;/td&gt;
          &lt;td&gt;        
              &lt;input name="" type="text" value="&lt;?php echo $answer ?&gt;" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;
  </code></pre>
  
  <p></p>