Loop

Discussion in 'ASP General' started by Øyvind Isaksen, Mar 15, 2005.

  1. Hello!

    I store from 1 to 50 (depending on input from user) image names in session
    variables (not array), and put them in variables like this:

    For X = 1 To 50
    Execute("varImage_" & X & " = Session(""image_" & X & """)")
    Next`

    This work perfect, output is like this:
    varImage_1 = session("image_1")
    varImage_2 = session("image_2")
    varImage_3 = session("image_3") and so on...



    ---Here is what I try to do:--------------

    Now I'm stucked with almost the same "problem"... I need to create ut to 50
    SQL's in a loop like the other code.
    This code under will explain what I try to do, X shall go from 1 to 50. I
    just need to get this correct:

    For X = 1 To 50

    if varImage_X <> "" then SQL_X = "insert into tblImage (path,sort,artID)
    values ('"&varImage_X&"','X','"&dbArtID&"'); "

    'Make variable SQL_SaveImgs with all the SQL's:
    if varImage_X <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_X

    Next

    How can I do this so it works??

    -------------------------------------------


    Try to get this output:
    if varImage_1 <> "" then SQL_X = "insert into tblImage (path,sort,artID)
    values ('"&varImage_1&"','1','"&dbArtID&"'); "
    if varImage_2 <> "" then SQL_X = "insert into tblImage (path,sort,artID)
    values ('"&varImage_2&"','2','"&dbArtID&"'); "
    if varImage_3 <> "" then SQL_X = "insert into tblImage (path,sort,artID)
    values ('"&varImage_3&"','3','"&dbArtID&"'); " and so on....

    if varImage_1 <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_1
    if varImage_2 <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_2
    if varImage_3 <> "" then SQL_SaveImgs = SQL_SaveImgs & SQL_3 and so on....

    (Will later on use SQL_SaveImgs to save all images)

    -------------------------------------------



    Hope someone please can help me!!
    Regards,
    Mr Isaksen
     
    Øyvind Isaksen, Mar 15, 2005
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?VGltOjouLg==?=

    Loop the loop...

    =?Utf-8?B?VGltOjouLg==?=, Feb 16, 2005, in forum: ASP .Net
    Replies:
    2
    Views:
    1,417
    Karl Seguin
    Feb 16, 2005
  2. Steven

    while loop in a while loop

    Steven, Mar 24, 2005, in forum: Java
    Replies:
    5
    Views:
    2,290
    Tim Slattery
    Mar 30, 2005
  3. -
    Replies:
    12
    Views:
    717
    Remon van Vliet
    Jun 15, 2005
  4. Byte
    Replies:
    4
    Views:
    438
  5. Isaac Won
    Replies:
    9
    Views:
    457
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page