I would like to know which is the best way to sort table columns with PHP and MySQL. Is there a way to do this without having to set a variables like the following?
$strASC = $_GET["order"];
if ($strASC == "ASC")
{
$strASC = "DESC";
}
or does exist an SQL query that reverses the ASC or DESC depending on current status?
When you get a result set from a database it is in the order you specify. The database does not reorder the data in it’s tables so therefore it does not know which “status” it is currently in.
Also watch out for SQL Injection in your example.