I am trying to concatenate a variable to my sql query in php to have my table sorted according to that variable. For eg:
if ($_GET['sort'] == 'Val'){
$query .= " ORDER BY val";
}
I need a variabvle $sortorder to be concatenated with this query. so that i get sorted query in ASC or DESC. What i do is
$order = ASC ;
if ($_GET['sort'] == 'Val'){
$query .= " ORDER BY val" ."$order";
}
and write the logic for
if($order==ASC){$order= DESC}
and vice versa. but it doesnt work. table is not displayed. some syntax issue?
Anyone could help on this. ?
valand the sort order.ASCandDESCdefined constants?$order = 'ASC';