Forums

ASP

This topic is locked

Using a Default image when none is found

Posted 21 Sep 2006 19:00:57
1
has voted
21 Sep 2006 19:00:57 bry keen posted:
Hello, I have tried everything and cannot get this to work. For some reason I either can get all of the existing images shown or all of the default images showing. All i am trying to do is show a default image
if one is not in the db. Keep in mind for some reason the db admin placed all of these images inside the db.

here is what i have so far to no success. this displays the existing images but leaves a blank image when and image dioes not exist in the db.

<%
Dim PicShow
PicShow = Recordset1.Fields.Item("ID".Value
IF PicShow <>"" THEN%>
<img src="www.domain.com/golfIncludes/gcPhotos.asp?id=<%=PicShow%>">
<%ELSE%>
<img src="www.domain.com/images/GCPhotos/genericGolf.jpg"><%End If%>

Replies

Replied 23 Sep 2006 17:23:30
23 Sep 2006 17:23:30 lou castro replied:
i am no expert at all....actually im a newbie, but I think your variable is wrong. Shouldnt it be PicshPicShow = Recordset1.Fields.Item("<font color=red>PICTUREFIELD</font id=red>".Value

I may be wrong...
Replied 25 Sep 2006 04:23:52
25 Sep 2006 04:23:52 Wim Conix replied:
Hello,

Isn't this what you meant to do ?
In case the image is to be shown on gcPhotos.asp and "ID" is the imagefile field.
Also check the database for the empty fields.
They can contain NULL values instead of empty values.
If so, change the = "" to IS NULL

&lt;%IF (Recordset1.Fields.Item("ID".Value) = "" THEN%&gt;
&lt;img src="www.domain.com/images/GCPhotos/genericGolf.jpg"&gt;
&lt;%ELSE Response.Redirect "www.domain.com/golfIncludes/gcPhotos.asp?id=(Recordset1.Fields.Item("ID".Value)" END IF%&gt;

Hope this helps, greetzz,

Wim



Wim Conix
www.image-belle.com

Reply to this topic