Link to home
Start Free TrialLog in
Avatar of asaworker
asaworker

asked on

Update sql table using coldfusion query and loop

I have a table that I need to clear values first then update it with correct data. It needs to happen 3 times. For some reason it's only happening once.
Please see code below:

<cfquery name="updateFeaturedCourse" datasource="#application.dsName#" username="#application.dsUserName#" password="#application.dsPassword#">
                        UPDATE courses
                        SET featuredcourse = 'N', featuredcourseordernumber = 0
                        WHERE featuredcourse = 'Y'
                <cfloop from="1" to="3" index="ThisRow">
                        <!--- extract each value --->
                  UPDATE courses
                  SET featuredcourse = 'Y', featuredcourseordernumber = '#Evaluate('form.hcf_#ThisRow#')#'
                  WHERE courseid ='#Evaluate('form.hf_#ThisRow#')#'
                        </cfloop>
            </cfquery>
                  <cflocation url="set_featured_courses.cfm?aid=m" addtoken="no">
ASKER CERTIFIED SOLUTION
Avatar of rob_lorentz
rob_lorentz

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial