Jump to content

Show image if recordset empty


jonnewbie12

Recommended Posts

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?

Link to comment
https://forums.phpfreaks.com/topic/250512-show-image-if-recordset-empty/
Share on other sites

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" />

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.