Firs we need to add a sort option to the Title of the column
array_push($td_titles,"140-CLIENT:sort:NAME");
In this example 140 is the width of the column, CLIENT is the title to show and sort:CLIENT indicates that it will sort the table by the column NAME.
Then we need to add the conditional before our query that will modify the order of the results, $orderby and $asde are predefined variables, in the first part we define our defaults, in this case order by REG_DATE DESC:
if(!isset($ob)){ $orderby = 'REG_DATE'; $asde = 'DESC'; }else{ $orderby = $ob; }
And finally incorporate these variables to our query:
$query = "SELECT CID, NAME, EMAIL, TEL, REG_DATE FROM $dbtable %%WHERE%% order by $orderby $asde";
Comments