I'm not sure if I'm completely understanding the question, but I'll give it a shot. If you want to sum a column of data from a DB you could always use the mySql's SUM function...
$sql = "SELECT SUM(field) FROM table";
But if you just want to check to see if there are values greater than 0 why not just do this:
$sql = "SELECT * FROM students WHERE grade > 0";
$res = mysql_query($sql);
if(mysql_num_rows($res)>0) {
//display link because grades higher than 0 exist
} else {
//do something else
}