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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.