Using Radio Buttons to Filter Data : I have a database of records which display on the page, with pagination set up.  
This is all working fine.

However, I want to let users filter the records by date asc / desc by clicking a radio button on a sidebar.

- when a user clicks a radio button (asc / desc) the data should be filtered as per their choice. So the MySQL would be: 

    SELECT * FROM tasks ORDER BY date ASC; 
    SELECT * FROM tasks ORDER BY date DESC;
		 
- When a user clicks the clear filters button the data should go back to displaying the original results.

    SELECT * FROM tasks;

Can anyone help me out? Here is what I have set up so far, I have included my comments.

**HTML**

    <form action="" method="post">
    		<p>Date:</p> 
    			<input id="dateorderasc" type="radio" name="dateorder" onclick="javascript:submit()" value="dateasc"<?php if (isset($_POST['dateorder']) && $_POST['dateorder'] == 'dateasc') echo ' checked="checked"';?> /> <label for="dateasc">Newest &rsaquo; Oldest</label>
    			<br>
    			<input id="dateorderdesc" type="radio" name="dateorder" onclick="javascript:submit()" value="datedesc" <?php if (isset($_POST['dateorder']) && $_POST['dateorder'] == 'datedesc') echo ' checked="checked"';?> /> <label for="datedesc">Oldest &rsaquo; Newest</label><br>
    </form>

**PHP**

    //connect
                    include ("db.connect.php");
    
    //Retrieve the tasks from the database table
    $query = "SELECT * FROM tasks";
    $result = mysqli_query($dbc, $query) or die('Error querying database.');
    
    //If RadioButton Clicked Sort the Database by Date Asc / Desc
    if(isset($_POST['dateorder']) && !empty($_POST['dateorder'])){
    	if (($_POST['dateorder'] == 'dateasc') $query .= " ORDER BY date ASC";
    	if ($_POST['dateorder'] == 'datedesc') $query .= " ORDER BY date DESC";
    }
    
    mysqli_query($dbc, $query) or die('Error Refreshing the page: ' . mysqli_error($dbc));
    
    
    		include("dbresults.php");
    
            ?>