ColdFusion Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreColdFusion Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old January 28th, 2005, 10:00 AM
Shmoo Shmoo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 38 Shmoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 43 m 17 sec
Reputation Power: 4
Need help looping through an insert query

I have a form that uses CFLOOP to create indexed fields of the same name for multiple entries, such as:

name1, address1, state1
name2, address2, state2
name3, address3, state3

So when the user hits the submit button, those fieldnames are passed over, but I'm having trouble looping through the insert query to add those variables to the database. Here's what I'm trying:
Code:
<CFLOOP INDEX="i" FROM="1" TO="#final_loop_cnt#">
<CFQUERY NAME="addnames#i#" DATASOURCE="#datasource#">
INSERT into name_table
(group_number,
user_name,
user_street,
user_state)
values (#newgroupnumber#, 'evaluate(name#i#)', 'evaluate(address#i#)', 'evaluate(state#i#)')
</CFQUERY>
</CFLOOP>

I've tried so many variations of that 'evaluate(name#i#)'...I've tried it with the single quotes inside (evaluate('name#i#')), I've tried it using the formname ('evaluate(form.name#i#)'), I've tried it with the evaluate, without the evaulate, combinations of each, but no matter what I try, I can't get the query to recognize those variables I've passed over. What am I missing here? I don't know if this is a ColdFusion question or a database question, but any help would be, well, helpful

Reply With Quote
  #2  
Old January 28th, 2005, 10:16 AM
glively glively is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 17 glively User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 30 m 51 sec
Reputation Power: 0
Try this:

<cfloop index="variables.cnt" from="1" to="#final_loop_cnt#">
<cfset variables.fld = Evaluate("form.fldname#variables.cnt#")>

Reply With Quote
  #3  
Old January 28th, 2005, 10:49 AM
Shmoo Shmoo is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2004
Posts: 38 Shmoo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 6 h 43 m 17 sec
Reputation Power: 4
I found a different way to attack this, and it seems to work, so thanks anyway It has nothing to do with what I posted above, but I'm still curious if anyone has any other advice just for future reference.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreColdFusion Development > Need help looping through an insert query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT