you first read out the data in the database for the row, where you want the details link to be - than make an if statement (if there is a value in there, make the link)
eg.
you have two tables x (with little info) and y (with everything else) and you have a key to connect the two tables in the database - lets say subject_ID
so you make a query
$query=mysql_query ("select * from y WHERE subject_ID = '$subject_ID'");
$count=mysql_num_rows($query);
if ($count>0) {
?>
<a href=.....</a>
<?php
}
?>