jonw118 Posted January 7, 2009 Share Posted January 7, 2009 Have a very simple question, and my attempts haven't worked... what do I need to add to this code to make it not display an image if there isn't one uploaded? Right now it shows a broken image. <? $sql="select image from inputinfo where id='$id'"; $rez=mysql_query($sql,$dblnk); $row=mysql_fetch_array($rez); echo "<img src='admin/{$row['image']}' />"; ?> Thanks for any help! Link to comment https://forums.phpfreaks.com/topic/139777-dont-display-image-if-null/ Share on other sites More sharing options...
darkfreaks Posted January 7, 2009 Share Posted January 7, 2009 <?php $sql="select image from inputinfo where id='$id'"; $rez=mysql_query($sql,$dblnk); $row=mysql_fetch_array($rez); if($row['image']=="NULL" && $row['image']=="") {}else{ echo "<img src='admin/{$row['image']}' />"; } ?> Link to comment https://forums.phpfreaks.com/topic/139777-dont-display-image-if-null/#findComment-731272 Share on other sites More sharing options...
Sesquipedalian Posted January 7, 2009 Share Posted January 7, 2009 Something similar should also suffice: <? $sql="select image from inputinfo where id='$id'"; $rez=mysql_query($sql,$dblnk); if ($rez) { $row=mysql_fetch_array($rez); echo "<img src='admin/{$row['image']}' />"; } ?> Link to comment https://forums.phpfreaks.com/topic/139777-dont-display-image-if-null/#findComment-731322 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.