How to add another column inside ASP script?

Dear EE experts,

We would like to ask for tech support on how to add another column with this script:
<% dim iRow
iRow=0
Do Until rsProducts.EOF
image1 = rsProducts("path_image")
image2 = rsProducts("image2")
image3 = rsProducts("image3")
image4 = rsProducts("image4")
image5 = rsProducts("image5")

The path_image is the location of the image & the image1-5 is the filename of the image.
So it should be path_image/image1

Thank you and hope to hear soon...
Stiebel EltronAsked:
Who is Participating?
 
Pratima PharandeCommented:
iRow=0
Do Until rsProducts.EOF

if ( rsProducts("image1") === NULL ) then
image1 = rsProducts("image1")
else
image1 = rsProducts("path_image") & "/" & rsProducts("image1")
end if

if ( rsProducts("image2")  === NULL ) then
image2 = rsProducts("image2")
else
image2 = rsProducts("path_image") & "/" & rsProducts("image2")
end if

if ( rsProducts("image3")  === NULL ) then
image3 = rsProducts("image3")
else
image3 = rsProducts("path_image") & "/" & rsProducts("image3")
end if

if ( rsProducts("image4")  === NULL ) then
image4 = rsProducts("image4")
else
image4 = rsProducts("path_image") & "/" & rsProducts("image4")
end if

if ( rsProducts("image5")  === NULL) then
image5 = rsProducts("image5")
else
image5 = rsProducts("path_image") & "/" & rsProducts("image5")
end if
0
 
PeteEngineerCommented:
0
 
Pratima PharandeCommented:
<% 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")
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
Stiebel EltronAuthor Commented:
I tried the advise of pratima_mcs, but is it possible that if there are no image on the db, no need to show a box with "x"?
0
 
Pratima PharandeCommented:
for that you need to put if loop of each image to wheter to display the image or not

someting like this

<?php
if (rsProducts("image1") <> "") then
?>

display image here

<? end if ?>
0
 
Stiebel EltronAuthor Commented:
Actually, before I ask to add that rsProducts("path_image"), it's working smoothly, if there are no image, it won't show any box with "x" in it.
Please see the attached code for reference...
Btw, I'm using ASP scripts not PHP... :-)
<% 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("download1")
				
 				if(download1 & ""= "") then
      				download1 = rsProducts("product_file")
      			if(download1&""<>"" ) then
          			download1="photo/"&download1
					'download1=download1
      			end if
				end if
				 'if(download1 & ""= "") then 
					'download1 = rsProducts("product_file")
				 'end if 

				 download2 = rsProducts("download2")
 				 download3 = rsProducts("download3")
				 download4 = rsProducts("download4")				 
				 download5 = rsProducts("download5")				 
			   	%>

Open in new window

0
 
Pratima PharandeCommented:
try like this
 
<% dim iRow
iRow=0
Do Until rsProducts.EOF 

if ( rsProducts("image1") == "" ) then
image1 = rsProducts("image1")
else
image1 = rsProducts("path_image") & "/" & rsProducts("image1")
end if 

if ( rsProducts("image2") == "" ) then
image2 = rsProducts("image2")
else
image2 = rsProducts("path_image") & "/" & rsProducts("image2")
end if 

if ( rsProducts("image3") == "" ) then
image3 = rsProducts("image3")
else
image3 = rsProducts("path_image") & "/" & rsProducts("image3")
end if 

if ( rsProducts("image4") == "" ) then
image4 = rsProducts("image4")
else
image4 = rsProducts("path_image") & "/" & rsProducts("image4")
end if 

if ( rsProducts("image5") == "" ) then
image5 = rsProducts("image5")
else
image5 = rsProducts("path_image") & "/" & rsProducts("image5")
end if

Open in new window

0
 
Stiebel EltronAuthor Commented:
I received this error:
Microsoft VBScript compilation error '800a03ea'

Syntax error

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

if ( rsProducts("image1") == "" ) then
---------------------------^

0
 
Stiebel EltronAuthor Commented:
Still receiving the same error & line.
I was thinking, is it because of the codes below this code?
if ( rsProducts("image5")  === NULL) then
image5 = rsProducts("image5")
else
image5 = rsProducts("path_image") & "/" & rsProducts("image5")
end if


product_name = rsProducts("product_name")
                         download1 = rsProducts("download1")
                        
                         if(download1 & ""= "") then
                              download1 = rsProducts("product_file")
                        if(download1&""<>"" ) then
                            download1="photo/"&download1
                              'download1=download1
                        end if
                        end if
                         'if(download1 & ""= "") then
                              'download1 = rsProducts("product_file")
                         'end if

                         download2 = rsProducts("download2")
                          download3 = rsProducts("download3")
                         download4 = rsProducts("download4")                        
                         download5 = rsProducts("download5")                        
                           %>
0
 
Stiebel EltronAuthor Commented:
Or maybe you can help me construct the IF THEN ELSE statement for this:
<td align="center" bordercolor="#000000" bgcolor="#FFFFFF">
                      <%= GetImage(Image1,download1,product_name)%>
</td>

If Image1 <> empty, then show image1, else don't show anything...

Thank you...
0
 
EyalCommented:
Hi again... sorry it's holiday here :)
as you can see you have already the check you ask for (4)

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

Open in new window

0
 
Stiebel EltronAuthor Commented:
@Eyal, I'll insert that @ GetImage part? right?
Please remove the photo as well, because my colleague change the script, no need the "photo" as well... huh! lol
0
 
EyalCommented:
so? everything is ok? or you still have problem?

0
 
Stiebel EltronAuthor Commented:
Now, I'm having problem...
0
 
Stiebel EltronAuthor Commented:
Please ignore my response @ ID: 36814727, I made a mistake with that response... I'll check it later then give my soonest response...
0
 
Stiebel EltronAuthor Commented:
@Eyal, I tried already the script that you advised, and received this error:

Microsoft VBScript compilation error '800a0409'

Unterminated string constant

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

RV = RV & "</a>""
-----------------^

I changed the script that you advised me earlier & replaced with that one (above), but receive that error result...
0
 
EyalCommented:
remove the double quote from the end
0
 
Stiebel EltronAuthor Commented:
@Eyal, I still receive the box of image with "x" inside, kindly see the attached screenshot for it...
What we want to happen is to not to show those image boxes if there are no image from the db...
ID27360821.jpg
0
 
Stiebel EltronAuthor Commented:
@Eyal, at this moment, I changed back and use the code that you advised, please see the attached codes. It's working, but the problem is if there's no image from the db, it shows a box with "x" in it. I would like to get rid of that boxes if images are not present from the db...

Thank you!
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
 
Stiebel EltronAuthor Commented:
Excellent!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.