jonnewbie12 Posted November 5, 2011 Share Posted November 5, 2011 Hi again probably a very simple code but not working. I am trying to show a default image "fabric.jpg" if the recordset is empty. If not empty it shows the recordset image at a size of 100X100. This is the code I am using and have probably left something out, any ideas? <img src="<?php if ($row_Recordset3['fabricpicture']==null); echo "<img src='graphics/fabric.jpg'>"; ?>" alt="" name="fabric" width="100" height="100" border="0" align="bottom" id="fabric" title="Selected Bottom Up Blind Fabric" /> I have tried switching the img scr both "" and ' ' but still no joy? Quote Link to comment https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/ Share on other sites More sharing options...
watsmyname Posted November 5, 2011 Share Posted November 5, 2011 HI $row_Recordset3['fabricpicture']=="" will work Quote Link to comment https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/#findComment-1285276 Share on other sites More sharing options...
Pikachu2000 Posted November 5, 2011 Share Posted November 5, 2011 It is unlikely that the value is actually NULL. It's probably just empty. This should work for you to echo the default image filename if there isn't one in the record, or the filename in the record if it's not empty. You might have to tweak the path to the actual file, if the full path isn't part of the record in the DB. <?php $image = empty( $row_Recordset3['fabricpicture'] ) ? 'graphics/fabric.jpg' : $row_Recordset3['fabricpicture']; ?> <img src="<?php echo $image: ?>" alt="" name="fabric" width="100" height="100" border="0" align="bottom" id="fabric" title="Selected Bottom Up Blind Fabric" /> Quote Link to comment https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/#findComment-1285278 Share on other sites More sharing options...
jonnewbie12 Posted November 5, 2011 Author Share Posted November 5, 2011 Sadly neither of these two ideas seem to work and have tried putting the full http:// path in for the graphic. Can you think of anything else that may be wrong? Quote Link to comment https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/#findComment-1285297 Share on other sites More sharing options...
Pikachu2000 Posted November 5, 2011 Share Posted November 5, 2011 If you View ---> Source is the url for the image correct, or empty, or . . . ? Quote Link to comment https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/#findComment-1285298 Share on other sites More sharing options...
jonnewbie12 Posted November 5, 2011 Author Share Posted November 5, 2011 Got it thanks. there was a : instead of ; after image in second code. Thanks very much for your help. I love this site Quote Link to comment https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/#findComment-1285300 Share on other sites More sharing options...
Pikachu2000 Posted November 5, 2011 Share Posted November 5, 2011 Yeah, I guess I missed that when I cut some of the text. Quote Link to comment https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/#findComment-1285302 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.