Solved

How to add another column inside ASP script?

Posted on 2011-09-28
20
260 Views
Last Modified: 2012-05-12
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...
0
Comment
Question by:Stiebel Eltron
  • 12
  • 4
  • 3
  • +1
20 Comments
 
LVL 8

Expert Comment

by:PeteEngineer
Comment Utility
0
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
<% 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
 

Author Comment

by:Stiebel Eltron
Comment Utility
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
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
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
 

Author Comment

by:Stiebel Eltron
Comment Utility
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
 
LVL 39

Expert Comment

by:Pratima Pharande
Comment Utility
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
 

Author Comment

by:Stiebel Eltron
Comment Utility
I received this error:
Microsoft VBScript compilation error '800a03ea'

Syntax error

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

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

0
 
LVL 39

Accepted Solution

by:
Pratima Pharande earned 500 total points
Comment Utility
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
 

Author Comment

by:Stiebel Eltron
Comment Utility
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
 

Author Comment

by:Stiebel Eltron
Comment Utility
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
Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

 
LVL 15

Expert Comment

by:Eyal
Comment Utility
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
 

Author Comment

by:Stiebel Eltron
Comment Utility
@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
 
LVL 15

Expert Comment

by:Eyal
Comment Utility
so? everything is ok? or you still have problem?

0
 

Author Comment

by:Stiebel Eltron
Comment Utility
Now, I'm having problem...
0
 

Author Comment

by:Stiebel Eltron
Comment Utility
Please ignore my response @ ID: 36814727, I made a mistake with that response... I'll check it later then give my soonest response...
0
 

Author Comment

by:Stiebel Eltron
Comment Utility
@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
 
LVL 15

Expert Comment

by:Eyal
Comment Utility
remove the double quote from the end
0
 

Author Comment

by:Stiebel Eltron
Comment Utility
@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
 

Author Comment

by:Stiebel Eltron
Comment Utility
@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
 

Author Closing Comment

by:Stiebel Eltron
Comment Utility
Excellent!
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Boost your ability to deliver ambitious and competitive web apps by choosing the right JavaScript framework to best suit your project’s needs.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

744 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now