hey there,

so i have a table in php that outputs the title, author, abstract and other
info from scolarly papers into. it pulls the data from a mysql database. at the
top of the table, i have two headers for title and author. i want to turn these
headers into links that when clicked will sort the data based on the appropiate
information. so, when the page loads, all the papers load in defualt order,
when the header "title" is clicked, the papers will appear in alph. order based
on titles, when it is clicked again, the papers appear in inverseorder. similar
for the header "author" when clicked --> sort based on order, clicked again -->
sort inverse order. any ideas? im new to php and mysql. thanks! here is my code:

<div id="main">
<br />
<table width="607" border="0" cellpadding="2" cellspacing="2">
<tr>
<th></th>
<th>Title</th>
<th>Author</th>
</tr>
<?
include 'library/connection.php';

mysql_connect($host,$username,$password);
@mysql_select_db($database) or die( "Unable to select database");

$query="SELECT * FROM paper";
$result=mysql_query($query);
$num=mysql_numrows($result);

$i=0;
while ($i < $num) {
$title=mysql_result($result,$i,"title");
$author=mysql_result($result, $i, "author");
$content=mysql_result($result, $i, "content");
$type=mysql_result($result, $i, "type");
$size=mysql_result($result, $i, "size");
$abstract=mysql_result($result, $i, "abstract");

$is_even = ($i % 2);

If ($is_even == 0)
{
echo "<tr class = \"block\">";
}
else {echo "<tr>";}

$author_search =
"http://scholar.google.com/scholar?hl=en&lr=&sa=G&oi=qs&q=author:".$author

?>

<td rowspan="2"><div align="center"><a href="<? echo "$content"; ?>"><img
src="images/icon_pdf.gif" alt="download pdf" /></a><br />
(<? echo "$size"; ?>Mb)</div></td>
<td><a href="<? echo "$content"; ?>"><? echo "$title"; ?></a></td>
<td><a href="<? echo "$author_search"; ?>" title="click to Google this author"
><? echo "$author"; ?></a></td>
</tr>
<?
If ($is_even == 0)
{
echo "<tr class = \"block\">";
}
else {echo "<tr>";}
?>
<td colspan="2"><? echo "$abstract"; ?></td>

<?
$i++;
} //end of loop

mysql_close();

?>

</table>
</div>