?
Solved

How to not to show additional image boxes in showing images in ASP?

Posted on 2011-10-02
20
Medium Priority
?
196 Views
Last Modified: 2012-05-12
Dear EE experts,

We would like to ask for tech support on how to remove those image boxes that don't have any image on it. It's because there's no image available on the db.
We just want to show images that are available on its db. Please see the attached screenshot & codes for it...

Thank you & hope to hear soon...
<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<tr> 
    
				<% dim iRow
				iRow=0
				Do Until rsProducts.EOF 
				image1 = rsProducts("path_image") & "/" & rsProducts("image1")
				image2 = rsProducts("path_image") & "/" & rsProducts("image2")
				image3 = rsProducts("path_image") & "/" & rsProducts("image3")
				image4 = rsProducts("path_image") & "/" & rsProducts("image4")
				image5 = rsProducts("path_image") & "/" & rsProducts("image5")
				image6 = rsProducts("path_image") & "/" & rsProducts("image6")
				 product_name = rsProducts("product_name")
				 download1 = rsProducts("path_download") & "" & rsProducts("download1")
				
 				if(download1 & ""= "") then
      				download1 = rsProducts("product_file")
      			if(download1&""<>"" ) then
          			download1="photo/"&download1
					'download1=download1
      			end if
				end if
				
				 download2 = rsProducts("path_download") & "" & rsProducts("download2")
 				 download3 = rsProducts("path_download") & "" & rsProducts("download3")
				 download4 = rsProducts("path_download") & "" & rsProducts("download4")				 
				 download5 = rsProducts("path_download") & "" & rsProducts("download5")				 
			   	%>

		</tr>
        <tr>
    		<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="5">
                      <b><%= product_name%></b>
        	</td>
    	</tr>
		<tr>
	    	<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
                	<%= GetImage(Image1,download1,product_name)%>
            </td>
		<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
                	<%= GetImage(Image2,download2,product_name)%>
            </td>
		<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
					<%= GetImage(Image3,download3,product_name)%>
            </td>
		<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
					<%= GetImage(Image4,download4,product_name)%>
            </td>
		<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
					<%= GetImage(Image5,download5,product_name)%>
            </td>
		<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
					<%= GetImage(Image6,download5,product_name)%>
            </td>

	</tr>
   <%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="5" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = ""
        bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
	end if
	GetImage = RV
End Function
%>

Open in new window

remove-box.jpg
0
Comment
Question by:Stiebel Eltron
  • 9
  • 8
  • 2
  • +1
20 Comments
 
LVL 83

Expert Comment

by:leakim971
ID: 36901238
put this in the head section :

<script language="javascript" type="text/javascript">
window.onload = function() {
    var images = document.getElementsByTagName("img");
    for(var i=0;i<images.length;i++) {
         images[i].onerror = function() {
             this.src = "http://www.eicc.be/images/NoImageAvailable.jpg";
             //this.parentNode.removeChild(this);
         }
    }
}
</script>

Open in new window

0
 

Author Comment

by:Stiebel Eltron
ID: 36901257
@leakim971: Still the same. I put it inside <head> </head> section, but the image box with "x" inside are still visible... :-(
0
 
LVL 83

Expert Comment

by:leakim971
ID: 36901347
could you give me a link to you page
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:Stiebel Eltron
ID: 36901402
I'm sorry, but we don't have online, only local intranet...
0
 
LVL 15

Expert Comment

by:Eyal
ID: 36901505
Hi again stiebel,
probably it happens because the images are not found in the server.
please use this code (added some debug information that can help and made some order in the code also
if image will not be found what should happen? do you want to put some kind of default image?


<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<% dim iRow, DebugMode
	iRow=0
    DebugMode = true
	Do Until rsProducts.EOF 
	image1 = rsProducts("path_image") & "/" & rsProducts("image1")
	image2 = rsProducts("path_image") & "/" & rsProducts("image2")
	image3 = rsProducts("path_image") & "/" & rsProducts("image3")
	image4 = rsProducts("path_image") & "/" & rsProducts("image4")
	image5 = rsProducts("path_image") & "/" & rsProducts("image5")
	image6 = rsProducts("path_image") & "/" & rsProducts("image6")
    if
	product_name = rsProducts("product_name")
	download1 = rsProducts("path_download") & "" & rsProducts("download1")
				
 	if(download1 & ""= "") then
      	download1 = rsProducts("product_file")
      	if(download1&""<>"" ) then
          	download1="photo/"&download1
      	end if
	end if
	download2 = rsProducts("path_download") & "" & rsProducts("download2")
 	download3 = rsProducts("path_download") & "" & rsProducts("download3")
	download4 = rsProducts("path_download") & "" & rsProducts("download4")				 
	download5 = rsProducts("path_download") & "" & rsProducts("download5")	
   	if DebugMode = true	then
        response.write("<tr><td colspan=""6"">" & image1 & "<br/>" &image2 & "<br/>" &image3 & "<br/>" &image4 & "<br/>" &image5 & "<br/>" &image6 & "</td></tr>")
    end if
	%>
    <tr>
    	<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="6">
            <b><%= product_name%></b>
        </td>
    </tr>
	<tr>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
            <%= GetImage(Image1,download1,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
            <%= GetImage(Image2,download2,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
			<%= GetImage(Image3,download3,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image4,download4,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image5,download5,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image6,download5,product_name)%>
        </td>
	</tr>
   <%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = ""
        bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
	end if
	GetImage = RV
End Function
%>

Open in new window


0
 

Author Comment

by:Stiebel Eltron
ID: 36901524
Hello to you again Eyal!
Tried your advise & got this error result:
Microsoft VBScript compilation error '800a03ea'

Syntax error

/iphoto/asia2/ste-shower-units.asp, line 150

if
--^

Hope to hear again soon...
0
 
LVL 15

Expert Comment

by:Eyal
ID: 36901531
what if is located in 150 row? I don't have all the page code here :)
0
 

Author Comment

by:Stiebel Eltron
ID: 36901541
Yes. It's the "If" statement... Please see the attached codes for reference.... :-)
<%@LANGUAGE="VBSCRIPT" CODEPAGE="65001"%>
<%
Set connectString = Server.CreateObject("ADODB.Connection")
connectString.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & _
Server.MapPath ("..\asia2\photo\products_asia.mdb") & ";"
connectString.Open

SeriesID = request.QueryString("SeriesID")

Set sqlContent = CreateObject("ADODB.Command")
sqlContent.ActiveConnection=connectString
sqlContent.Prepared = true

sqlContent.commandtext = "SELECT products.ID, products.seriesid, products.product_name, products.path_image, products.image1, products.image2, products.image3, products.image4, products.image5, products.image6, products.path_download, products.download1, products.download2, products.download3, products.download4, products.download5, products.product_file, products.updateby, products.updatedate, series.typeid, series.categoryid, series.brandid, series.series_name FROM products INNER JOIN series ON products.seriesid = series.seriesid WHERE products.seriesid=?"

sqlContent.Parameters.Append sqlContent.CreateParameter("@seriesid", 3, 1, , SeriesID)
Set rsProducts = sqlContent.Execute
if not rsProducts.eof then
series_name = rsProducts("series_name")
end if
%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>

<meta name="Author" content="IT" />
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<meta http-equiv="Content-Type" content="text/html; charset=windows-874" />

<meta name="GENERATOR" content="Mozilla/4.7 [en] (Win98; I) [Netscape]" />


<title>..:: Stiebel Eltron's iPhoto Stock Gallery - Powered by STE IT Dept. ::..</title>
<style type="text/css">
<!--
	a
 	{
  		color:#000080;
		font-family:verdana;
		text-decoration:none;
		font-size:12px
	}
	
	
	a:active
 	{
  		color:red;

	}

	a:hover
 	{
  		color:#FF0000;
		text-decoration:none;
		cursor:crosshair;
	}
		
	table
	{
		font-family:verdana;
	}
	
	td
	{
		font-family:verdana;
		font-size:10e;
	}

	.b
	{
		font-color:#0A0EB7;
	}		

-->
</style>

<!--date-->
<script type="text/javascript">

<!-- Begin
dayName = new Array("", "¿¿¿¿¿¿", "¿¿¿¿¿¿", "¿¿¿", "¿¿¿¿¿¿¿¿", "¿¿¿¿¿", "¿¿¿¿¿", "¿¿¿¿¿¿¿")
monName = new Array("¿¿¿¿¿¿", "¿¿¿¿¿¿¿¿¿¿", "¿¿¿¿¿¿", "¿¿¿¿¿¿", "¿¿¿¿¿¿¿", "¿¿¿¿¿¿¿¿", "¿¿¿¿¿¿¿", "¿¿¿¿¿¿¿", "¿¿¿¿¿¿¿", "¿¿¿¿¿¿", "¿¿¿¿¿¿¿¿¿", "¿¿¿¿¿¿¿")
now = new Date
//  End -->
</script>

<script src="Scripts/AC_RunActiveContent.js" type="text/javascript"></script>

</head>

<body bgproperties="fixed" bgcolor="#000000" onload="javascript:startmenu()">
<table width="760" border="0" cellspacing="3" cellpadding="1">
  <tr>
    <td><img src="IMG/logo_res.jpg" alt="STIEBEL ELTRON" /></td>
    <td valign="top" bgcolor="#666666"><object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0" width="548" height="197">
      <param name="movie" value="homeintro20.swf" />
      <param name="quality" value="high" />
      <param name="wmode" value="opaque" />
      <embed src="homeintro20.swf" quality="high" wmode="opaque" pluginspage="http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash" type="application/x-shockwave-flash" width="548" height="197"></embed>
    </object></td>
    <td><img src="IMG/white_square.png" alt="STIEBEL ELTRON" /></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td align="right" bgcolor="#999999"><font face="Verdana, Geneva, sans-serif" color="#ffffff">
    <%
   '// If user is logged in show name and logout link
   If Session("loggedin") = true Then
      Response.Write "Welcome: " & Session("name")
      Response.Write "<br /><a href=""../asia2/login2/logout.asp"">Logout</a>"
   Else
      Response.Write "<a href=""ste-iphoto-login.asp"" title=""CLICK TO LOGIN"">REGISTERED USERS</a>"
   End If
	%>&nbsp;
	</td>
    <td bgcolor="#666666" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    
    <td align="left" bordercolor="#999999" bgcolor="#FFFFFF">
    » <img src="IMG/imgfolder.gif" alt="" />&nbsp;
       <%if rsProducts.eof then
	response.Write"STE Shower Units - <br><br><center>Sorry, there is no product images for that ID...</center>"
	else%>
    <a href="javaScript:menu0func()">STE Shower Units - <b><font face="verdana" size="+1"> - 
	<%=series_name%></font></b></a><%end if%>
	</td>
	<td bgcolor="#999999" align="center">&nbsp;</td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    
	<td align="left" bordercolor="#999999" bgcolor="#FFFFFF">
<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<tr> 
    
	<% dim iRow, DebugMode
	iRow=0
    DebugMode = true
	Do Until rsProducts.EOF 
	image1 = rsProducts("path_image") & "/" & rsProducts("image1")
	image2 = rsProducts("path_image") & "/" & rsProducts("image2")
	image3 = rsProducts("path_image") & "/" & rsProducts("image3")
	image4 = rsProducts("path_image") & "/" & rsProducts("image4")
	image5 = rsProducts("path_image") & "/" & rsProducts("image5")
	image6 = rsProducts("path_image") & "/" & rsProducts("image6")
    if
	product_name = rsProducts("product_name")
	download1 = rsProducts("path_download") & "" & rsProducts("download1")
				
 	if(download1 & ""= "") then
      	download1 = rsProducts("product_file")
      	if(download1&""<>"" ) then
          	download1="photo/"&download1
      	end if
	end if
	download2 = rsProducts("path_download") & "" & rsProducts("download2")
 	download3 = rsProducts("path_download") & "" & rsProducts("download3")
	download4 = rsProducts("path_download") & "" & rsProducts("download4")				 
	download5 = rsProducts("path_download") & "" & rsProducts("download5")	
   	if DebugMode = true	then
        response.write("<tr><td colspan=""6"">" & image1 & "<br/>" &image2 & "<br/>" &image3 & "<br/>" &image4 & "<br/>" &image5 & "<br/>" &image6 & "</td></tr>")
    end if
	%>
    <tr>
    	<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="6">
            <b><%= product_name%></b>
        </td>
    </tr>
	<tr>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
            <%= GetImage(Image1,download1,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
            <%= GetImage(Image2,download2,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
			<%= GetImage(Image3,download3,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image4,download4,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image5,download5,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image6,download5,product_name)%>
        </td>
	</tr>
   <%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = ""
        bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
	end if
	GetImage = RV
End Function
%>        			

  		<tr>

Open in new window

0
 
LVL 17

Expert Comment

by:sonawanekiran
ID: 36901543
Try this

<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<% dim iRow, DebugMode
	iRow=0
    DebugMode = true
	Do Until rsProducts.EOF 
	image1 = rsProducts("path_image") & "/" & rsProducts("image1")
	image2 = rsProducts("path_image") & "/" & rsProducts("image2")
	image3 = rsProducts("path_image") & "/" & rsProducts("image3")
	image4 = rsProducts("path_image") & "/" & rsProducts("image4")
	image5 = rsProducts("path_image") & "/" & rsProducts("image5")
	image6 = rsProducts("path_image") & "/" & rsProducts("image6")
    if
	product_name = rsProducts("product_name")
	download1 = rsProducts("path_download") & "" & rsProducts("download1")
				
 	if(download1 & ""= "") then
      	download1 = rsProducts("product_file")
      	if(download1&""<>"" ) then
          	download1="photo/"&download1
      	end if
	end if
	download2 = rsProducts("path_download") & "" & rsProducts("download2")
 	download3 = rsProducts("path_download") & "" & rsProducts("download3")
	download4 = rsProducts("path_download") & "" & rsProducts("download4")				 
	download5 = rsProducts("path_download") & "" & rsProducts("download5")	
   	if DebugMode = true	then
        response.write("<tr><td colspan=""6"">" & image1 & "<br/>" &image2 & "<br/>" &image3 & "<br/>" &image4 & "<br/>" &image5 & "<br/>" &image6 & "</td></tr>")
    end if
	%>
    <tr>
    	<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="6">
            <b><%= product_name%></b>
        </td>
    </tr>
	<tr>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
            <%= GetImage(Image1,download1,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
            <%= GetImage(Image2,download2,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
			<%= GetImage(Image3,download3,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image4,download4,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image5,download5,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image6,download5,product_name)%>
        </td>
	</tr>
   <%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = ""
        bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
        Else
         RV = RV & "<img src=""http://www.eicc.be/images/NoImageAvailable.jpg""  style=""border:0px;""/>"
	end if
       
	GetImage = RV
End Function
%>

Open in new window

0
 

Author Comment

by:Stiebel Eltron
ID: 36901551
@sonawanekiran: Tried it, but still the same... :-(
0
 
LVL 15

Expert Comment

by:Eyal
ID: 36901553
remove line 150

<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<% dim iRow, DebugMode
	iRow=0
    DebugMode = true
	Do Until rsProducts.EOF 
	image1 = rsProducts("path_image") & "/" & rsProducts("image1")
	image2 = rsProducts("path_image") & "/" & rsProducts("image2")
	image3 = rsProducts("path_image") & "/" & rsProducts("image3")
	image4 = rsProducts("path_image") & "/" & rsProducts("image4")
	image5 = rsProducts("path_image") & "/" & rsProducts("image5")
	image6 = rsProducts("path_image") & "/" & rsProducts("image6")
	product_name = rsProducts("product_name")
	download1 = rsProducts("path_download") & "" & rsProducts("download1")
				
 	if(download1 & ""= "") then
      	download1 = rsProducts("product_file")
      	if(download1&""<>"" ) then
          	download1="photo/"&download1
      	end if
	end if
	download2 = rsProducts("path_download") & rsProducts("download2")
 	download3 = rsProducts("path_download") & rsProducts("download3")
	download4 = rsProducts("path_download") & rsProducts("download4")				 
	download5 = rsProducts("path_download") & rsProducts("download5")	
   	if DebugMode = true	then
        response.write("<tr><td colspan=""6"">" & image1 & "<br/>" &image2 & "<br/>" &image3 & "<br/>" &image4 & "<br/>" &image5 & "<br/>" &image6 & "</td></tr>")
    end if
	%>
    <tr>
    	<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="6">
            <b><%= product_name%></b>
        </td>
    </tr>
	<tr>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
            <%= GetImage(Image1,download1,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
            <%= GetImage(Image2,download2,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
			<%= GetImage(Image3,download3,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image4,download4,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image5,download5,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image6,download5,product_name)%>
        </td>
	</tr>
   <%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = ""
        bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
	end if
	GetImage = RV
End Function
%>

Open in new window

0
 
LVL 15

Expert Comment

by:Eyal
ID: 36901606
we can add code to check if images/downloads exist but you must tell us what you desire to happen
0
 

Author Comment

by:Stiebel Eltron
ID: 36901757
What we desire to happen is to not to show those image boxes if there's no images in the db...

Please see the attached screenshot for the result from the latest codes that you advised...
remove-box2.jpg
0
 
LVL 15

Expert Comment

by:Eyal
ID: 36901782
try this...
<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<% dim iRow, DebugMode
	iRow=0
    DebugMode = true
	Do Until rsProducts.EOF 
	image1 = iif(rsProducts("image1")&""="","",rsProducts("path_image") & "/" & rsProducts("image1"))
	image2 = iif(rsProducts("image2")&""="","",rsProducts("path_image") & "/" & rsProducts("image2"))
	image3 = iif(rsProducts("image3")&""="","",rsProducts("path_image") & "/" & rsProducts("image3"))
	image4 = iif(rsProducts("image4")&""="","",rsProducts("path_image") & "/" & rsProducts("image4"))
	image5 = iif(rsProducts("image5")&""="","",rsProducts("path_image") & "/" & rsProducts("image5"))
	image6 = iif(rsProducts("image6")&""="","",rsProducts("path_image") & "/" & rsProducts("image6"))
	product_name = rsProducts("product_name")
	download1 = rsProducts("path_download") & "" & rsProducts("download1")
				
 	if(download1 & ""= "") then
      	download1 = rsProducts("product_file")
      	if(download1&""<>"" ) then
          	download1="photo/"&download1
      	end if
	end if
	download2 = rsProducts("path_download") & rsProducts("download2")
 	download3 = rsProducts("path_download") & rsProducts("download3")
	download4 = rsProducts("path_download") & rsProducts("download4")				 
	download5 = rsProducts("path_download") & rsProducts("download5")	
   	if DebugMode = true	then
        response.write("<tr><td colspan=""6"">" & image1 & "<br/>" &image2 & "<br/>" &image3 & "<br/>" &image4 & "<br/>" &image5 & "<br/>" &image6 & "</td></tr>")
    end if
	%>
    <tr>
    	<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="6">
            <b><%= product_name%></b>
        </td>
    </tr>
	<tr>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
            <%= GetImage(Image1,download1,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
            <%= GetImage(Image2,download2,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
			<%= GetImage(Image3,download3,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image4,download4,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image5,download5,product_name)%>
        </td>
	    <td align="center" bordercolor="#000000" bgcolor="#FFFFFF">                
			<%= GetImage(Image6,download5,product_name)%>
        </td>
	</tr>
   <%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = ""
        bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
	end if
	GetImage = RV
End Function
%>

Open in new window

0
 
LVL 15

Expert Comment

by:Eyal
ID: 36901797
sorry missed the iif function

Function IIf(i,j,k)
	If i Then IIf = j Else IIf = k
End Function

Open in new window



put it before the GetImage function
0
 

Author Comment

by:Stiebel Eltron
ID: 36901842
Kindly check the attached codes, and please let me know where did I made a mistake...
Still the same error result...
Loop

Function IIf(i,j,k)
	If i Then IIf = j Else IIf = k
End Function 

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = ""
        bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
	end if
	GetImage = RV
End Function
%>

Open in new window

0
 
LVL 15

Expert Comment

by:Eyal
ID: 36901862
another improvement...
if there is error note me the line

<table width="78%" border="0" cellspacing="3" cellpadding="1">
	<% dim iRow, DebugMode
	iRow=0
    DebugMode = true
	Do Until rsProducts.EOF 
	image1 = GetImagePath(1)
	image2 = GetImagePath(2)
	image3 = GetImagePath(3)
	image4 = GetImagePath(4)
	image5 = GetImagePath(5)
	image6 = GetImagePath(6)
	product_name = rsProducts("product_name")
	download1 = iif(rsProducts("download1")&""="","",rsProducts("path_download") & "" & rsProducts("download1"))
				
 	if(download1 & ""= "") then
      	download1 = rsProducts("product_file")
      	if(download1&""<>"" ) then
          	download1="photo/"&download1
      	end if
	end if
	download2 = rsProducts("path_download") & rsProducts("download2")
 	download3 = rsProducts("path_download") & rsProducts("download3")
	download4 = rsProducts("path_download") & rsProducts("download4")				 
	download5 = rsProducts("path_download") & rsProducts("download5")	
   	if DebugMode = true	then
        response.write("<tr><td colspan=""6"">" & image1 & "<br/>" &image2 & "<br/>" &image3 & "<br/>" &image4 & "<br/>" &image5 & "<br/>" &image6 & "</td></tr>")
    end if
	%>
    <tr>
    	<td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="6">
            <b><%= product_name%></b>
        </td>
    </tr>
	<tr>
        <%= GetImage(Image1,download1,product_name)%>
        <%= GetImage(Image2,download2,product_name)%>
		<%= GetImage(Image3,download3,product_name)%>
		<%= GetImage(Image4,download4,product_name)%>
		<%= GetImage(Image5,download5,product_name)%>
		<%= GetImage(Image6,download5,product_name)%>
	</tr>
   <%
	iRow = iRow + 1
	if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
	<tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
	<%end if
	rsProducts.MoveNext()
Loop

Function iif(i,j,k)
	If i Then iif = j Else iif = k
End Function

Function GetImagePath(ImageIndex)
    GetImagePath = iif(rsProducts("image"&ImageIndex)&""="","",rsProducts("path_image") & "/" & rsProducts("image"&ImageIndex))
End Function

Function GetImage(Image,download,productname)
	dim RV, bGenerateLink
	RV = "<td align=""center"" bordercolor=""#000000"" bgcolor=""#FFFFFF"">"
    bGenerateLink = false
	if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
		If bGenerateLink  Then
			RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
			'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
		End If
		RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
		If bGenerateLink  Then
			RV = RV & "</a>"
		End If
	end if
	GetImage = RV & "</td>"
End Function
%>

Open in new window

0
 

Author Comment

by:Stiebel Eltron
ID: 36901881
It removes the image boxes, but still have this:
PROD-IMG/Accessories//v_boo_dog01.jpg
PROD-IMG/Accessories//v_boo_dog02.jpg
PROD-IMG/Accessories//v_blue-rose.jpg
PROD-IMG/Accessories//v_blue-rose.jpg
above each row of images...

And is it possible to have only 1 "/" between Accessories & image filename?
0
 
LVL 15

Accepted Solution

by:
Eyal earned 2000 total points
ID: 36901888
<table width="78%" border="0" cellspacing="3" cellpadding="1">
      <% dim iRow, DebugMode
      iRow=0
    DebugMode = false
      Do Until rsProducts.EOF
      image1 = GetImagePath(1)
      image2 = GetImagePath(2)
      image3 = GetImagePath(3)
      image4 = GetImagePath(4)
      image5 = GetImagePath(5)
      image6 = GetImagePath(6)
      product_name = rsProducts("product_name")
      download1 = iif(rsProducts("download1")&""="","",rsProducts("path_download") & "" & rsProducts("download1"))
                        
       if(download1 & ""= "") then
            download1 = rsProducts("product_file")
            if(download1&""<>"" ) then
                download1="photo/"&download1
            end if
      end if
      download2 = rsProducts("path_download") & rsProducts("download2")
       download3 = rsProducts("path_download") & rsProducts("download3")
      download4 = rsProducts("path_download") & rsProducts("download4")                        
      download5 = rsProducts("path_download") & rsProducts("download5")      
         if DebugMode = true      then
        response.write("<tr><td colspan=""6"">" & image1 & "<br/>" &image2 & "<br/>" &image3 & "<br/>" &image4 & "<br/>" &image5 & "<br/>" &image6 & "</td></tr>")
    end if
      %>
    <tr>
          <td style="background-color:#FFFFFF;border-color:#999999;text-align:left;vertical-align:top;" colspan="6">
            <b><%= product_name%></b>
        </td>
    </tr>
      <tr>
        <%= GetImage(Image1,download1,product_name)%>
        <%= GetImage(Image2,download2,product_name)%>
            <%= GetImage(Image3,download3,product_name)%>
            <%= GetImage(Image4,download4,product_name)%>
            <%= GetImage(Image5,download5,product_name)%>
            <%= GetImage(Image6,download5,product_name)%>
      </tr>
   <%
      iRow = iRow + 1
      if iRow mod 5 = 0 then ' let say you want to add empty line after 5 rows %>
      <tr><td colspan="6" bgcolor="#FFFFFF"></td></tr>
      <%end if
      rsProducts.MoveNext()
Loop

Function iif(i,j,k)
      If i Then iif = j Else iif = k
End Function

Function GetImagePath(ImageIndex)
    GetImagePath = iif(rsProducts("image"&ImageIndex)&""="","",rsProducts("path_image") & rsProducts("image"&ImageIndex))
End Function

Function GetImage(Image,download,productname)
      dim RV, bGenerateLink
      RV = "<td align=""center"" bordercolor=""#000000"" bgcolor=""#FFFFFF"">"
    bGenerateLink = false
      if Trim(Image & "") <>"" then
               bGenerateLink = (download&""<>"") and Session("loggedIn") = true
            If bGenerateLink  Then
                  RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "photo/download") & """>"
                  'RV = RV & "<a href=""" & Replace(download, "DOWNLOAD", "download") & """>"
            End If
            RV = RV & "<img src=""photo/" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
            'RV = RV & "<img src=""" & image & """ alt=""" & Server.HTMLEncode(productname) &""" style=""border:0px;""/>"
            If bGenerateLink  Then
                  RV = RV & "</a>"
            End If
      end if
      GetImage = RV & "</td>"
End Function
%>
0
 

Author Closing Comment

by:Stiebel Eltron
ID: 36902392
Excellent! I'll just check other details, regarding links for download & show image, but it worked!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Originally, this post was published on Monitis Blog, you can check it here . It goes without saying that technology has transformed society and the very nature of how we live, work, and communicate in ways that would’ve been incomprehensible 5 ye…
Originally, this post was published on Monitis Blog, you can check it here . In business circles, we sometimes hear that today is the “age of the customer.” And so it is. Thanks to the enormous advances over the past few years in consumer techno…
Viewers will get an overview of the benefits and risks of using Bitcoin to accept payments. What Bitcoin is: Legality: Risks: Benefits: Which businesses are best suited?: Other things you should know: How to get started:
The viewer will get a basic understanding of what section 508 compliance can entail, learn about skip navigation links, alt text, transcripts, and font size controls.
Suggested Courses
Course of the Month15 days, 11 hours left to enroll

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question