$id = "id"; $ip = "offender"; $date = "tstamp"; $sort_order = "$date"; //our SQL query $sql_query = "SELECT id, offender, tstamp FROM banned_ips ORDER BY" . $sort_order . "ASC"; //store the SQL query in the result variable $result = mysql_query($sql_query);
My question is I want to be able to allow the order by to be changed from within a variable. How can I set the oreder by to be a variable which can be changed without have to change the actual code?