title: Update PHP variable onchange of select field
body: <p>I am working off a snippet of someone else's code I have found. I would like to update a PHP variable once the select field has changed.</p>
  
  <p>The name of the of the variable is $ProductType as below. The current code does what is expected so now all I'd like to do is set the variable equal to the changed option</p>
  
  <pre><code>&lt;?php
    $ProductType = '';
  
    if(isset($_GET['trade'])){
      //Everything in here will get echoed in the DIV
      echo "You selected: ".$_GET['trade'];
      $ProductType = $_GET['trade']; // I'd have thought this might work but when I echo $ProductType, it returns nothing.
      exit;
    }
  
  ?&gt;
  &lt;script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3/jquery.min.js"&gt;&lt;/script&gt;
  
  &lt;form name="x" action="" method="POST"&gt;
    &lt;select name="trade" onchange="$('#extra').load('?trade='+this.value);"&gt;
      &lt;option value="1"&gt;item1&lt;/option&gt;
      &lt;option value="2"&gt;item2&lt;/option&gt;
      &lt;option value="3"&gt;item3&lt;/option&gt;
      &lt;option value="4"&gt;item4&lt;/option&gt;
    &lt;/select&gt;
    &lt;input type="submit" value="SEARCH" class="submit-button btn" /&gt;
  &lt;/form&gt;
  
  &lt;div id="extra" style="color:red;"&gt;&lt;/div&gt;
  </code></pre>
  
  <p><strong>EDIT:</strong></p>
  
  <p>I've added a search button this time. I've echoed it out again and it seems it is working, however, it is returning an array which is not what I am after.
  So once the page loads, the user will select from the dropdown and the variable $ProductType should change. If I then submit the form, the page loads again and my variable updates my query.</p>