Forums

PHP

This topic is locked

Show default image if recordset is empty

Posted 31 Mar 2005 15:50:34
1
has voted
31 Mar 2005 15:50:34 Matt Bailey posted:
Can you use PHP to show a default image if the image field in a database row is empty?

I'm creating a news page, but the client may not always upload an image with a news story. I know how to hide the area, but this leaves a big blank space. It would be much better if a default image were to appear.

___________________________________
* Sorry... how do you do that again?... *

Replies

Replied 31 Mar 2005 15:55:35
31 Mar 2005 15:55:35 Dean Blackborough replied:
<pre id=code><font face=courier size=2 id=code>
if($row_recordset['Image'] &lt;&gt; NULL) {
// Show Recordset Image
} else {
// Show Default Image
}
</font id=code></pre id=code>

Assuming the db field is left NULL else you will have to test for string length using strlen()

--------------------------------------
www.galleryof3d.com
(PHP and MySQL)
Replied 31 Mar 2005 18:29:15
31 Mar 2005 18:29:15 Matt Bailey replied:
That's fantastic! Thank you.

___________________________________
* Sorry... how do you do that again?... *

Reply to this topic