title: MYSQL/PHP - How to make a "Sort By" dropdown for sorting results drawn from mysql
body: <p>I would like to include a feature that lets users of my site sort the results of a search, either by name or by price.</p>
  
  <p>This is fairly simple as all i intend on doing is changing the mysql query, via php. </p>
  
  <p>So basically the query looks like this:</p>
  
  <pre><code>$searchResultQuery = "
      SELECT id, name, price
      FROM items
      WHERE MATCH (name)
      AGAINST ('{$GLOBALS['input']}' IN BOOLEAN MODE)
      ORDER BY $GLOBALS['sort']
  ";
  </code></pre>
  
  <p>And the html looks something like this:</p>
  
  <pre><code>&lt;form&gt;
  &lt;select name="sort" id="sort" style="float: left;"&gt;
      &lt;option value="name"&gt;Name&lt;/option&gt;
      &lt;option value="price"&gt;Price&lt;/option&gt;
  &lt;/select&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>What i want to do, is have the form automatically submit when  a new option is selection. As in, by default the results are ordered by name, but if the user chooses price, then it will adjust the results so display in order of their prices. This would happen without the user needing to click on a submit button of some sort.</p>
  
  <p>As i have a very bleak knowledge of javascript, I have been reading up on some of the html5 additions, and it seems that there is nothing to cover this. Is this possible without the use of javascript or am i forced to learn how to use the <code>onchange</code> attribute?</p>
  
  <p>If anyone has any input regarding this, it would be greatly appreciated, thank you!</p>
  
  <p>EDIT:</p>
  
  <p>This would be what i have added to the controller, although i assume this is the reason that is is not being passed:</p>
  
  <pre><code>if (isset($_POST['sort']))
  {   
      $GLOBALS['sort'] = $_POST['sort'];
  }
  </code></pre>
  
  <p>How would i add the forms value to the globals variable?</p>