this is my solution, there are others:
ok you have this as the a href link:
<a href=index.php?sort=$t>" . $t . "</a>
so when that actual column is the one being sorted on:
if ($sort==$t) echo "<a href=index.php?sort=$t&dsc=1>" . $t . "</a>";
then do a get on 'dsc' and if set change "ORDER BY $sort ASC" to "ORDER BY $sort DESC"
and make sure a href reverts to plain "<a href=index.php?sort=$t>" . $t . "</a>";
I tend to leave out the ASC in SQL statements as ASC is the default behaviour
you can add things to alter text colour of the column being sorted or add a little arrow image that changes colour and direction depending if ASC or DESC sorting