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! Quote Link to comment 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']}' />"; } ?> Quote Link to comment 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']}' />"; } ?> Quote Link to comment 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.