I am not sure where my error is but it says Sort is undefined and also an error about Invalid query: Erreur de syntaxe près de 'GROUP BY Mall ORDER BY Counter DESC' à la ligne 1
Here is an excerpt of my code about regarding the display of stores.
if(isset($_GET['formSubmit'])) 
    {
        $varStats = $_GET['formStats'];
        $errorMessage = "";
            switch($varStats)
            {
            case "ByAMEX": $sort = "AMEX = 1"; break;
            case "ByBDOTerminal": $sort = "BDOTerminal = 'YES'"; break;
            case "ByResto": $sort = "Resto = 'YES'"; break;
            case "ByCashOnly": $sort = "Cash = 'YES'"; break;
            case "ByPOSNotSeen": $sort = "POSNotSeen = 'YES'"; break;
            }
            $conn = db_connect();
            sortMall($conn, $sort);
            db_disconnect($conn);
            exit();
    }
Here is an excerpt where I initialized the Sort function:
function sortMall($conn, $sort)
{
$table = "test";
$column1 = "StoreName";
$column2 = "Mall";
$query1 = "Select $column2, Count($column1) AS Counter from $table where $sort GROUP BY $column2 ORDER BY Counter DESC"; 
$result = mysqli_query($conn, $query1);
    if ($result == FALSE)
    {
        echo "Invalid query: " . $conn->error;
        echo "<br/>";
        return;
    }
I actually have another function that almost does the same with the same syntax and all, it works. I don't know why this does not.
 
     
     
    