What I do on a similar page I wrote, is pass a sort variable. Then I have a switch in my page:
PHP Code:
switch ($_REQUEST["sort"])
{
case 'gyasc':
$orderby = "ORDER BY fieldx ASC";
break;
case 'gydesc':
$orderby = "ORDER BY fieldx DESC";
break;
case 'fieldyasc':
$orderby = "ORDER BY fieldy ASC";
break;
case 'fieldydesc':
$orderby = "ORDER BY fieldy DESC";
break;
.........
default:
$orderby = "ORDER BY fieldz DESC";
}
Then I add that variable to the end of my query:
PHP Code:
$query = "select blah, blah FROM ".$TABLE_PREFIX."thread as thread WHERE blah, blah' and thread.visible = 1 $orderby $limit";
And then just make your titles clickable and pass the sort variable:
HTML Code:
<a href="yourpage.php?sort=gydesc">Graduation Year</a>