In these lines:
<td valign="top"><a href="http://totten1.com/realestate/yourfiles5/' .nl2br($row['img1']) .
'">
<img src="http://totten1.com/realestate/yourfiles5/' .nl2br($row['img1']) .
'" height="161" width="300">
</a>
You should do this:
<td valign="top">
if($row['img1']!="" && $row['img1']!=null){
<a href="http://totten1.com/realestate/yourfiles5/' .nl2br($row['img1']) .
'">
<img src="http://totten1.com/realestate/yourfiles5/' .nl2br($row['img1']) .
'" height="161" width="300">
</a>
}
Or something like it...
And just a Q: why do you use nl2br function when you are displaying pictures?