with css
To hide an element you can use css: element:empty (such as p:empty) {display:none}
, or img[src=""] {display:none}
.
with mysql code
You can, even with PDO, use this syntax
if ($data[0]['somecolumn'] != '') {echo " " . $data[0]['somecolumn'] . "";}