title: How to sort table ascending and descending by click state? MYSQL/ColdFusion
body: <p>I have a table where I can click the headers to sort the whole table by different columns.
  I would like to incorporate some boolean state so that I can click once to sort the table by that column ascending then click again to have it descending.</p>
  
  <p>Here is my code:</p>
  
  <pre><code> &lt;th&gt;&lt;A HREF="thispage.cfm?sorter=creationDate"&gt;Creation Date&lt;/A&gt; &lt;/th&gt;
  
   &lt;cfif IsDefined("URL.sorter")&gt;
  
   &lt;cfquery datasource="Pad"  name="One"&gt;
   select * from meeting
   ORDER BY #URL.sorter# DESC
   &lt;/cfquery&gt;
  
  &lt;cfelse&gt;
   &lt;cfquery datasource="Pad" name="One"&gt;
  select * from meeting
   ORDER BY contactName
   &lt;/cfquery&gt;
  &lt;/cfif&gt;
  </code></pre>
  
  <p>I believe it could be implemented by creating a boolean variable using cfset and then altering that variable state on clicking the table header and assigning one variable state to ASC and another to DESC in the first query. I'm just not sure how to implement it.</p>