Well for starters you had a syntax error on line 8 which I fixed for you (you were missing a closing ' after xxx).
The typical way to do this is to add a link with specific _GET vars. I implemented this for a project years ago (PHP Support Tickets) by adding ?sort=colname&dir=direction as the href values for links in the headers.
The thing is, I don't see any table headers so you'll need to add those. Other than that, it's as easy as making the <th> elements have links that look like:
echo '<th><a href="?sort=' . $column . '&dir=' . $direction . '">' . $columnName . '</a></th>';
Then in your php, just see if the _GET values are set. If they are, appropriately account for them:
$query = "SELECT * FROM xxx where date = '$dt'";
if(isset($_GET['column']))
{
// Order by the column
$query .= "ORDER BY " . $_GET['column'];
if(isset($_GET['dir']))
$query .= " " . $_GET['dir'];
}
else
{
// Default sort order
$query .= "";
}
$data = mysql_query($query) or die('MYSQL Error');
So in the end you'd have links that looked like this in the URL:
?sort=Seiz&dir=ASC
?sort=Seiz&dir=DESC
?sort=BSCID&dir=ASC
?sort=BSCID&dir=DESC
?sort=Cellid&dir=ASC
....
Hope that helps.