Okay so i have managed to implement Sorting when you click the link of the thead. But if i want to change the asc to desc i have to change the code, is there any way using PHP where i can sort the table as descending if its showing as asc?
eg pseudo: If current column is asc then sort desc?
Here is my current code:
if (isset($_GET['sort'])) {
$sorting = $_GET['sort'];
$result = $mysqli->query("SELECT * FROM routes ORDER BY $sorting DESC");
}
This is my link structure:
Route ID
To confirm when the user clicks on the link it will sort and if they click the same link again it will sort opposite way.