468,512 Members | 1,481 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,512 developers. It's quick & easy.

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("UnitPrice3")%> is greater than 0. How do I write the if statement on my asp page?

Expand|Select|Wrap|Line Numbers
  1. <div class="orderItem">
  2. <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>
  3.                    <span>$<%=rs("UnitPrice3")%></span>
  4.                    <%=rs("ProductName3")%>
  5. </div>
  6.  
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 Images
File Type: jpg unitprice.jpg (880 Bytes, 207 views)
Sep 17 '10 #1
2 1576
jhardman
3,405 Expert 2GB
Expand|Select|Wrap|Line Numbers
  1. <div class="orderItem">
  2. <%
  3. if rs("unitprice3") > 0 then %>
  4.    <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>
  5.                       <span>$<%=rs("UnitPrice3")%></span>
  6. <%
  7. end if %>
  8.                    <%=rs("ProductName3")%>
  9. </div>
  10.  
Is this what you are looking for?

Jared
Sep 17 '10 #2
Yes - thank you! That worked.
Sep 17 '10 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by RSH | last post: by
reply views Thread by NPC403 | last post: by
1 post views Thread by fmendoza | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.