If statement when retrieving variable from database

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Meditrina
    New Member
    • Sep 2010
    • 4

    If statement when retrieving variable from database

    I have code that looks like this (pulling in 3 fields from a sql database), but I want it to only show the fields if <%=rs("UnitPric e3")%> is greater than 0. How do I write the if statement on my asp page?

    Code:
    <div class="orderItem">
    <a href="http://www.xyz.com/eshop/shop.asp?productcode=<%=rs("ProductCode3")%>" title="Order"><img src="http://bytes.com/images/order.gif" alt="Order" /></a>
                       <span>$<%=rs("UnitPrice3")%></span>
                       <%=rs("ProductName3")%>
    </div>
    I've attached an image of what I get without the IF statement - I don't want to see the order button or the $ if the unit price is <0.

    Thanks for any help.
    Attached Files
    Last edited by jhardman; Sep 17 '10, 06:02 AM. Reason: added code tags. please use code tags in the future
  • jhardman
    Recognized Expert Specialist
    • Jan 2007
    • 3405

    #2
    Code:
    <div class="orderItem">
    <%
    if rs("unitprice3") > 0 then %>
       <a href="http://www.xyz.com/eshop/shop.asp?productcode=<%=rs("ProductCode3")%>" title="Order"><img src="http://bytes.com/images/order.gif" alt="Order" /></a>
                          <span>$<%=rs("UnitPrice3")%></span>
    <%
    end if %>
                       <%=rs("ProductName3")%>
    </div>
    Is this what you are looking for?

    Jared

    Comment

    • Meditrina
      New Member
      • Sep 2010
      • 4

      #3
      If Statement

      Yes - thank you! That worked.

      Comment

      Working...