Create a button that will sort a MYSQL query ascending and descending
===

I'm a student coder. 
I want to create a sort button that when pressed, sorts a MYSQL query in Ascending order. Then when pressed again, it will sort in Descending order. Right, now, it just shows both Ascending and Descending tables back to back.

What's the best way to form this button's logic? 

Thanks.
P.L.
     
      <form name="Email Header" method="post" action="{$_SERVER['PHP_SELF']}">
        <button type="submit" name="id_sort" class="button" value="1">ID</button>
        <button type="submit" name="from_sort" class="button" value="1">FROM</button>
        <button type="submit" name="to_sort" class="button" value="1">TO</button>
        <button type="submit" name="subject_sort" class="button" value="1">SUBJECT</button>
        <button type="submit" name="date_sort" class="button" value="1">DATE</button>
     </form>


    // SORT 

    if( isset( $_POST['id_sort'] ) )
       if( $_POST['id_sort'] == 1 )
         id_ASC_sort();
         $_POST['id_sort'] = 0;
   
    if ($_POST['id_sort'] = 0)
      if( isset( $_POST['id_sort'] ) )
         if( $_POST['id_sort'] == 1 ) 
            id_DESC_sort();


     // query
        $sql = "SELECT * FROM messages ORDER BY message_id DESC";
        $result = mysql_query( $sql );



