I’m trying to insert movie data into my database using a cfloop.

I have a movie which must be link to a number if venues i.e. 20. On my input form I have a list of all the venues together with a yes/no dropdown box. The purpose is to say yes this movie is showing at this venue or visa versa.

When the form is activated it sends a comer separated list of venue IDs and yes/no’s to the insert statement. As can been seen from my code below I am using a cfloop to add the data which works.


it loops though the data and instead of adding 20 records it adds 800. If I remove one of the cfloop’s i.e. the yes/no loop then it adds the correct number of records (20). This doesn’t help when I need to recall the data because I need the yes/no field.

What am I doing wrong? Can someone please help?????


[<cfloop index="i" list="#FORM.theatersBrID#" >
<cfloop index="b" list="#FORM.ven_status#">
<cfset a = #i# & #b#>

<cfquery datasource="#REQUEST.DataSource#" name="#a#" >
INSERT INTO tbl_movies_venue (moviesID,
<cfif IsDefined("FORM.moviesID") AND #FORM.moviesID# NEQ "">
<cfqueryparam value="#FORM.moviesID#" cfsqltype="cf_sql_clob" maxlength="50">
<cfif IsDefined("i") AND #i# NEQ "">
<cfqueryparam value="#i#" cfsqltype="cf_sql_clob" maxlength="50">
<cfif IsDefined("FORM.ven_times") AND #FORM.ven_times# NEQ "">
<cfqueryparam value="#FORM.ven_times#" cfsqltype="cf_sql_clob" maxlength="150">
<cfif IsDefined("b") AND #b# NEQ "">
<cfqueryparam value="#b#" cfsqltype="cf_sql_clob" maxlength="50">
<!--- close loop ---></cfloop>

Help will be appreciated

10 Years
Discussion Span
Last Post by kingzulu

So, I have been able to resolve this issue... (See my first posting)

I my attempt I have reverted to using an editable cfgrid which seen to work to the point that the I now seen to find the cfgridupdate tag doesn't seem to work in ColdFusion 7.02. Has anybody else had the same problem???

If not have a look at my code, maybe I’m just stupid!!!!


<cfquery datasource="#REQUEST.DataSource#" name="getThe">
SELECT tbl_movies_venues.*
FROM tbl_movies_venues
WHERE tbl_movies_venues.moviesID = '#URL.moviesID#'


<cfgrid name="myGrid2" query="getThe" height="250" colheaders="yes" rowheaders="no" selectmode="edit">
<cfgridcolumn name="venueID" header="Venue ID" select="no" />
<cfgridcolumn name="moviesID" header="Movie ID" select="no" />
<cfgridcolumn name="theatersBrID" header="Theatres ID" select="no" />
<cfgridcolumn name="ven_status" header="Venue" select="yes" />
<cfgridcolumn name="ven_times" header="Time" select="yes" />
<cfformgroup type="horizontal">
<cfinput type="submit" name=”addit” value="Add Theaters to Movie">

ACTION PAGE (this is on a different page)

<cfgridupdate grid="myGrid2" dataSource="#REQUEST.DataSource#" tableName="tbl_movies_venues"/>

Any help will be appreciated

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.