Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

Hide Images from DB

LEGEND ,
Apr 20, 2006 Apr 20, 2006
How can you completely hide placeholders in a table cell when images,
are NOT to be shown or called from a database?
Like here - http://www.webewitch.com/classifieds/classads_basic.asp
Thanks
Gary


TOPICS
Server side applications
394
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
Apr 20, 2006 Apr 20, 2006
This is probably the easiest thing I have looked at all day. First, make sure you have a 1px transparent image. I am also assuming that you are calling your images from a file and that the name is being pulled by a recordset from a name in your database and that the code loops until EOF. If so, use the following code block where your image recordset is:

<%Dim PicShow
PicShow = rsEx2.Fields.Item("shMainPic").Value
IF PicShow <>"" THEN%>
<img src="<%=PicShow%>">
<%ELSE%>
<img src="pix/no_pic.jpg">
<%End If%>

Now, I know you are probably asking, "What are we doing?"

- First we are declaring a Variable and naming it PicShow .
- Next we give PicShow a value equal to the contents of rsEx1.Fields.Item("shMainPic").Value
- We then start our IF THEN routine by saying that IF the contents of PicShow is not empty (<> -- not equal to "" -- empty) THEN we must execute the next line of code. Which happens to be <img src="<%=PicShow%>"> (remember that PicShow now holds the value of the image path)
- So what happens if PicShow IS empty? That's where the ELSE comes in with ELSE execute the next line of code. Which happens to be a standard HTML image path to our default image " <img src="pix/no_pic.jpg"> "
- END IF tells the page that this particular IF THEN routine is over!

In short ........... IF the dynamic picture field is not empty THEN display the dynamic picture, otherwise ELSE display a standard static picture.

Let me know if this is clear or not. Good luck and keep coding!
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Apr 20, 2006 Apr 20, 2006
LATEST
Sorted, many thanks for the swift reply
Gary


Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines