Wrox Programmer Forums
| Search | Today's Posts | Mark Forums Read
Classic ASP Professional For advanced coder questions in ASP 3. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Professional section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #1 (permalink)  
Old November 20th, 2007, 02:24 PM
Authorized User
Join Date: Mar 2007
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts
Default Help with Array and Loop

Looking for help with the code below -
The idea is to locate comma delimited data (checkbox values gathered from dynamic form to dynamic table) and separate it out so that each value can be checked against a value in a table to retrieve an email address.
The issue is that it stops checking the array value against the table after the first increment. And I guess I have looked at it too long because I can't see the forest for the trees...


'============================ASP CODE============================================== =====
If instr(RSEnduserData(myCol),",") <>0 then
response.Write("There is more than one answer for this question.<BR>")
            for i=i to u
            response.write("Array Answers: "& ansArray(i)&"<BR>")
            Set rsContactsToAnswers = Server.CreateObject("ADODB.Recordset")
            rsContactsToAnswers.Open "Select* from ContactsToAnswers where QID='"&myQ&"'", Conn, 2, 2

            if rsContactsToAnswers("Answer")=ansArray(i) then
            if rsContactsToAnswers("level")="1" then
            response.write(rsContactsToAnswers("contactEmail") &" QID="&myQ&"<BR>")
            end if
            end if
end if

'==========================================OUTPUT= ================================================
Column Name:Q22 == 22
Enduser Answer: Mickey Mouse
Column Name:Q23 == 23
Enduser Answer: this is a test of the email routing
Column Name:Q24 == 24
Enduser Answer: DD
Column Name:Q25 == 25
Enduser Answer: BB, JJ, GJ, MM, DD
There is more than one answer for this question.
Array Answers: BB
bettyboop@yahoo.com QID=25
Array Answers: JJ
Array Answers: GJ
Array Answers: MM
Array Answers: DD

===============================TABLE DATA============================================== ==========
Answer ContactEmail Flag Level instanceNum QID ContactID
BB bettyboop@yahoo.com BB 1 60 25 1483
GJ georgejetson@yahoo.com GJ 1 60 25 1484
MM mickeymouse@yahoo.com MM 1 60 25 1485
JJ judyjetson@yahoo.com JJ 1 60 25 1486
DD donaldduck@yahoo.com DD 1 60 25 1487

  #2 (permalink)  
Old November 20th, 2007, 02:34 PM
Wrox Author
Points: 13,255, Level: 49
Points: 13,255, Level: 49 Points: 13,255, Level: 49 Points: 13,255, Level: 49
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Oct 2005
Location: Ohio, USA
Posts: 4,104
Thanks: 1
Thanked 64 Times in 64 Posts
Send a message via AIM to dparsons

I can see why you are confused. Here is the problem:
rsContactsToAnswers.Open "Select* from ContactsToAnswers where QID='"&myQ&"'", Conn, 2, 2

That statement, I assume, returns 4 rows all the time (QID = 25) and the reason that the loop works the first time through is because rsContactsToAnswers("Answer") contains BB and so does position 0 of your array but the problem is that you increment your array each time the For loop executes but you never loop your recordset, you only check the first row of data which will always return the answer BB.

Solution: Loop your recordset =]

================================================== =========
Read this if you want to know how to get a correct reply for your question:
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
  #3 (permalink)  
Old November 21st, 2007, 07:50 AM
Authorized User
Join Date: Mar 2007
Location: , , .
Posts: 14
Thanks: 0
Thanked 0 Times in 0 Posts

Too simple 8^) Thanks so much!

Similar Threads
Thread Thread Starter Forum Replies Last Post
loop array problem dbrine Java Basics 2 June 15th, 2007 06:49 AM
Problem with loop and array katlees MySQL 1 July 5th, 2006 11:24 PM
Pass variables from array inside a loop dustygn PHP How-To 2 May 3rd, 2006 05:35 PM
create array for loop in FSO jfergy Classic ASP Professional 4 April 14th, 2006 09:59 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.