[thelist] ASP Loop Question

Veronica Yuill veronicay at archetype-it.com
Wed Mar 20 09:49:01 CST 2002


Josh,

I think you are looking for the Eval function. Try this for size:

<%
variable_1 = 1
variable_2 = 2
variable_3 = 3
variable_4 = 4
for x = 1 to 4
     variable = "variable_" & x
     response.write eval(variable) & "<br>"
next
%>

HTH

At 10:31 20/03/2002 -0500, you wrote:
>This message is in MIME format. Since your mail reader does not understand
>this format, some or all of this message may not be legible.
>--
>[ Picked text/plain from multipart/alternative ]
>I have 10 variables:
>
>variable_1 = "string1"
>variable_2 = "string2"
>...
>variable_10 = "string10"
>
>I want to insert the variable data into a database as a separate row.  I
>would also like to automate this process.
>
>I tried:
>
>for x = 1 to 10
>     variable = "variable_" & x
>     rs.Open "INSERT INTO database (column) VALUES (' " & variable & " ')"
>next
>
>The issue is that the string "variable_1" gets inserted in the database
>instead of "string1."

Veronica Yuill                 email: veronicay at archetype-it.com
Archetype Information Technology Ltd  http://www.archetype-it.com/english/
------------------------------------------------------------------
Dynamic websites for fast-moving businesses




More information about the thelist mailing list