ded Posted May 22, 2008 Share Posted May 22, 2008 With the code below, if the database does not have a picture in it, the dreaded "Box With An X in it" shows up. Is there a way to eliminate the middle "echo" code if nothing appears in the field "picture"? while($row = mysql_fetch_array($resultr)) { echo "<h2>" . $row['fname'] . " " . $row['lname'] . "</h2>"; echo "<img src=" . $row['picture'] . " class=newsimages>"; echo $row['comments']; } ?> Thanks, DED Link to comment https://forums.phpfreaks.com/topic/106717-solved-php-help-with-eliminating-code/ Share on other sites More sharing options...
sasa Posted May 22, 2008 Share Posted May 22, 2008 change to echo $row['picture'] ? "<img src=" . $row['picture'] . " class=newsimages>" : ''; Link to comment https://forums.phpfreaks.com/topic/106717-solved-php-help-with-eliminating-code/#findComment-547053 Share on other sites More sharing options...
ded Posted May 22, 2008 Author Share Posted May 22, 2008 Excellent......thank you!!!! Link to comment https://forums.phpfreaks.com/topic/106717-solved-php-help-with-eliminating-code/#findComment-547064 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.