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 Quote 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>" : ''; Quote 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!!!! Quote 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
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.