$sort = name;
if (!empty($_GET['sort'])) {
$sort = $_GET['sort'];
}
$host="localhost";
$user="book";
$pwd="";
$db=mysql_connect($host,$user,$pwd);
mysql_select_db("book",$db);
$result=mysql_query("SELECT * FROM comment ORDER BY $sort");
$n=mysql_num_rows($result);
echo "<br />Записей в БД: ".$n;
echo "<br />sort = ".$sort;
echo "<table border=10>";
echo "<tr><td><a href='http://php.loc/index.php?sort=name'>name</a></td><td><a href='http://php.loc/index.php?sort=email'>email</a></td><td><a href='http://php.loc/index.php?sort=comment'>Comments</a></td></tr>&qu ot;;
for($i=0;$i<$n;$i++) echo "<tr><td>",mysql_result($result,$i,name),"</td><td>",mysql_result($result,$i,email),"</td><td>",mysql_result($result,$i,comment),"</td></tr>";
echo "</table>";
здесь получается сортировка от а до я, а нужно зделать сортировку и от а до я и от я до а.