Gina,
Try this for inserting:
<cfloop index="i" FROM="1" TO= "6" > (change "to" to however many variables
sets you have)
<cfset Thisweek = Evaluate("week" & i)>
<cfset Thisclientid= Evaluate("Form.clientid" & i)>
<cfset Thisuserid = Evaluate("Form.clientid" & i)>
<cfset Thistaskid= Evaluate("form.taskid" & i)>
(do this for all your form variables)
<cfquery name="addrows" datasource="#dbname#">
INSERT INTO Timesheet (week, clientid, userid, taskid, ......)
VALUES ('#thisweek#', #thisclientied#, #thisuserid#, #thistaskid#,
.....)
</cfquery>
</cfloop>
As for updating... use the same idea for an UPDATE statement, using your
primary key data for the WHERE clause.
HTH,
Erika
----- Original Message -----
From: "Gina Shillitani" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Tuesday, September 05, 2000 11:42 AM
Subject: RE: Inserting (or updating) more than one record at a time
: I have three tables, Tasks, Clients, and Timesheet. I have to enter the
: timesheets by week rather than by date. What I'm having a hard time with
is
: inserting the individual records. There are multiple records, and they are
: named CLIENTID1, TASKID1, etc. with a loop on the page that submits the
: records for insertion. I can't figure out how to enter multiple records.
The
: Timesheet table insert for a single record looks like this:
:
: INSERT INTO
: Timesheet(Week,
: UserID,
: ClientID,
: TaskID,
: Sun,
: Mon,
: Tue,
: Wed,
: Thu,
: Fri,
: Sat)
: VALUES(#Week(Now())#,
: #UserID#,
: #ClientID#,
: #TaskID#,
: '#SunTime#',
: '#MonTime#',
: '#TueTime#',
: '#WedTime#',
: '#ThuTime#',
: '#FriTime#',
: '#SatTime#')
:
: I need to be able to run this insert query on multiple records to be
: inserted.
:
: -----Original Message-----
: From: John Allred [mailto:[EMAIL PROTECTED]]
: Sent: Tuesday, September 05, 2000 11:02 AM
: To: [EMAIL PROTECTED]
: Subject: Re: Inserting (or updating) more than one record at a time
:
:
: Gina,
:
: I don't have a specific response to your question, only a suggestion. If
: your form fields correspond to columns in a table, you might find
: everything much easier to deal with if you modify the structure of your
: database. You have, essentially, these types of information:
: CLIENTID1,TASKID1,SUNHOURS1,MONHOURS1,TUEHOURS1,WEDHOURS1,THUHOURS1,
: FRIHOURS1,SATHOURS1. To get different ClientIDs, you change the "1" to a
: different number and add new columns to the table.
:
: What you might consider is breaking this up into at least two tables, one
: for the ClientID, and the second one for the tasks and hours associated
: with that ID. All of the fields in the second table can have the ending
: number dropped, then be combined into a single table with only 9 columns.
: The ClientID field would be the link back to your Client table. Doing this
: will shrink the size and complexity of your database, make it easier to
add
: new ClientIDs, if needed, and make inserts, updates, and deletes, not to
: mention select queries, a snap to write.
:
: HTH,
: --John
:
:
:
:
:
: Gina Shillitani
:
: <gshillitani@Gecko To:
: "'[EMAIL PROTECTED]'"
: Media.com> <[EMAIL PROTECTED]>
:
: cc:
:
: 09/05/2000 08:10 Subject: Inserting (or
: updating) more than one record
: AM at a time
:
: Please respond to
:
: cf-talk
:
:
:
:
:
:
:
:
: I have more than one set of fields to insert or update in a table. See
: below
: for the fields and sample data... can someone tell me the best way to
: insert
: or update multiple rows?
:
: Form Fields:
:
:
FIELDNAMES=CLIENTID1,TASKID1,SUNHOURS1,MONHOURS1,TUEHOURS1,WEDHOURS1,THUHOUR
:
:
S1,FRIHOURS1,SATHOURS1,CLIENTID2,TASKID2,SUNHOURS2,MONHOURS2,TUEHOURS2,WEDHO
:
:
URS2,THUHOURS2,FRIHOURS2,SATHOURS2,CLIENTID3,TASKID3,SUNHOURS3,MONHOURS3,TUE
:
:
HOURS3,WEDHOURS3,THUHOURS3,FRIHOURS3,SATHOURS3,CLIENTID4,TASKID4,SUNHOURS4,M
:
:
ONHOURS4,TUEHOURS4,WEDHOURS4,THUHOURS4,FRIHOURS4,SATHOURS4,CLIENTID5,TASKID5
:
:
,SUNHOURS5,MONHOURS5,TUEHOURS5,WEDHOURS5,THUHOURS5,FRIHOURS5,SATHOURS5,SUBMI
:
: T
:
:
:
:
:
: --------------------------------------------------------------------------
--
: --
: Archives: http://www.mail-archive.com/[email protected]/
: To Unsubscribe visit
: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
: send a message to [EMAIL PROTECTED] with 'unsubscribe' in
: the body.
: --------------------------------------------------------------------------
----
: Archives: http://www.mail-archive.com/[email protected]/
: To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.