I got the cfloop working and I am now able to create a record in the
database. I want to make a small change however and I have it partly
working:
In the master list of names there is an id key which exists. I am now
displaying that as part of the select list, so that that it can be moved
across as well.
I dont necessarily need to display the id, but at present I am.
Basically I just want to be sure that I can save the id when I am writing
the records to the table.
Currently I am writing the id as part of the name in the table I am
creating.
I tried including the girlid into the insert into statement but then the
program crashed because there was only one column of data. #q# how do I get
the id and the name
Basically, how do I write 2 columns into the database.
Currently I am doing:
<cfset girls = '#form.sel#'>
<cfdump var="#form.sel#">
<!---
<cfdump var="Date = #insert_date# <br> Girls = #girls#">
--->
<cfloop list="#girls#" index="i">
<cfoutput>#i#<br></cfoutput>
</cfloop>
<cftransaction>
<CFQUERY datasource="#Request.DSN#">
DELETE
FROM testRoster
</CFQUERY>
<cfloop list="#girls#" index="q">
<cfquery name="insert" datasource="#Request.DSN#">
INSERT INTO testRoster (girl_name)
VALUES ('#q#')
</cfquery>
</cfloop>
</cftransaction>
-----Original Message-----
From: Peter Tanswell [mailto:[EMAIL PROTECTED]
Sent: Tuesday, 22 August 2006 4:04 AM
To: CF-Talk
Subject: creating a new record in a db table
OK here is a summary of what I'm trying to achieve.
I have displayed on the screen two select lists. A user is then able to
select names from one select list to the other. In fact, the select list on
the lest is a master list so all the names will appear in that list.
Lets say a user selects 10 names from the list on the left and moves them to
the list on the right.
When the user clicks submit I want to create a table that contains one
record for each name in the table on the right.
Currently I have the following:
I am displaying individual lines on the scree, but in the DB I am just
getting one record created, The format of the record being the id field and
then the name field which looks like:
Abby,Bthe,Cindy,Coral - basically comma delimted where as I want in this
case 4 separate records created in the DB.
Thanks in advance for any feedback
<cfset girls = '#form.sel#'>
<cfloop list="#girls#" index="i">
<cfoutput>#i#<br></cfoutput>
</cfloop>
<cfquery datasource="#Request.DSN#">
Insert into testRoster
(girl_name)
Values
('#girls#')
</cfquery>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting,
up-to-date ColdFusion information by your peers, delivered to your door four
times a year.
http://www.fusionauthority.com/quarterly
Archive:
http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250519
Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4