IF, END IF and ELSE? How do I add an ELSE?

Ask a Question related to Dreamweaver AppDev, Design and Development.

  1. #1

    Default IF, END IF and ELSE? How do I add an ELSE?

    Hi,

    I have a dynamic field in the database with an image reference. I have this
    set up as a Hide If Empty kind of idea, as follows:

    <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
    <img src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%> "
    border="1" alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
    <%End IF%>

    What do I need to add to this code in order to display an image, should the
    "photograph" field be empty?

    Thanks.
    Nath.


    Nathon Jones Guest

  2. #2

    Default Re: IF, END IF and ELSE? How do I add an ELSE?

    On 04 Mar 2005 in macromedia.dreamweaver.appdev, Nathon Jones wrote:
    > Hi,
    >
    > I have a dynamic field in the database with an image reference. I
    > have this set up as a Hide If Empty kind of idea, as follows:
    >
    > <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
    > <img
    > src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%>
    > " border="1" alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
    > <%End IF%>
    >
    > What do I need to add to this code in order to display an image,
    > should the "photograph" field be empty?
    <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
    <img src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%> " border="1"
    alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
    <% Else %>
    <img src="dog-photographs/noimage.jpg" border="1" alt="Sorry, no image">
    <%End IF%>

    where noimage.jpg is either a blank of the appropriate size, or
    something saying 'there's no dog here'.

    --
    Joe Makowiec
    [url]http://makowiec.net/[/url]
    Email: [url]http://makowiec.net/email.php[/url]
    Joe Makowiec Guest

  3. #3

    Default Re: IF, END IF and ELSE? How do I add an ELSE?

    You should also check for a NULL value from the database as follows:

    <%
    Dim Photo
    Photo = (rsDogInfo.Fields.Item("photograph").Value)

    IF NOT ISNULL(Photo) And Photo <> "" Then%>
    <img src="dog-photographs/<%=Photo%>" border="1"
    alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
    <%
    Else
    %>
    <img src="dog-photographs/noimage.jpg" border="1" alt="Sorry, no image">
    <%
    End IF
    %>

    Brendan


    "Joe Makowiec" <makowiec@invalid.invalid> wrote in message
    news:Xns960F40A4C5526makowiecatnycapdotrE@216.104. 212.96...
    > On 04 Mar 2005 in macromedia.dreamweaver.appdev, Nathon Jones wrote:
    >
    > > Hi,
    > >
    > > I have a dynamic field in the database with an image reference. I
    > > have this set up as a Hide If Empty kind of idea, as follows:
    > >
    > > <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
    > > <img
    > > src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%>
    > > " border="1" alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
    > > <%End IF%>
    > >
    > > What do I need to add to this code in order to display an image,
    > > should the "photograph" field be empty?
    >
    > <%IF (rsDogInfo.Fields.Item("photograph").Value) <> "" Then%>
    > <img
    src="dog-photographs/<%=(rsDogInfo.Fields.Item("photograph").Value)%> "
    border="1"
    > alt="<%=(rsDogInfo.Fields.Item("dogname").Value)%> ">
    > <% Else %>
    > <img src="dog-photographs/noimage.jpg" border="1" alt="Sorry, no image">
    > <%End IF%>
    >
    > where noimage.jpg is either a blank of the appropriate size, or
    > something saying 'there's no dog here'.
    >
    > --
    > Joe Makowiec
    > [url]http://makowiec.net/[/url]
    > Email: [url]http://makowiec.net/email.php[/url]

    Singularity.co.uk Guest

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139