The easiest way to do this would be to have all the headings on your results page be links with their querystring generated by the php code. These links would take the form:
<a href="search.php?sortby=title&sortdir=asc&(search related querystring data here)">Title</a>
You need to get the php to specify the search related querystring parameters and also the direction (depending on which field the current result list was sorted on and in which direction).
In your php code test for the values of $GET['sortby'] and $GET['sortdir']. Do a check to ensure that they both belong to a set of valid values ($GET['sortdir'] must be either ASC or DESC and $GET['sortby'] must be a valid field within your table) and then insert them into your query like so:
// initialize arrays of valid field names and sort directions
$fields = array('title', 'description', ...);
$sortdirs = array('ASC', 'DESC');
// obtain the values, if any, of $sortby and $sortdir
$sortby = $_GET['sortby'];
$sortdir = $_GET['sortdir'];
// check to see if they are valid values, if not set them to the sort values
if (!in_array(strtolower($sortby), $fields)) {
$sortby = 'title'; // the default sort field
}
if (!in_array(strtoupper($sortdir), $sortdirs)) {
$sortdir = 'ASC';
}
// interpolate those values into your querystring
$sql = "SELECT ... FROM ... WHERE ... ORDER BY $sortby $sortdir;";
in_array is case sensitive, hence the calls strtoupper() and strtolower() when searching these arrays.
Good luck,
Ryan