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.d sName#" username="#application.dsU serName#" password="#application.dsP assword#">
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_#This Row#')#'
WHERE courseid ='#Evaluate('form.hf_#This Row#')#'
</cfloop>
</cfquery>
<cflocation url="set_featured_courses. cfm?aid=m" addtoken="no">
Please see code below:
<cfquery name="updateFeaturedCourse
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_#This
WHERE courseid ='#Evaluate('form.hf_#This
</cfloop>
</cfquery>
<cflocation url="set_featured_courses.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.