Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | 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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #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...
Any help is MOST APPRECIATED!

thanks

'============================ASP CODE============================================== =====
If instr(RSEnduserData(myCol),",") <>0 then
response.Write("There is more than one answer for this question.<BR>")
ansArray=split(RSEnduserData(myCol),",")
u=ubound(ansArray)
            for i=i to u
            response.write("Array Answers: "& ansArray(i)&"<BR>")
            myArr=ansArray(i)
            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
            rsContactsToAnswers.close
            next
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


Reply With Quote
  #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
Default

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:
http://www.catb.org/~esr/faqs/smart-questions.html
================================================== =========
.: Wrox Technical Editor :.
Wrox Books 24 x 7
================================================== =========
Reply With Quote
  #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
Default

Too simple 8^) Thanks so much!

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:23 AM.


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