Update DB via specific checkbox inputs
Hey, this is killing me, i know its simple..
I have a cfoutput query showing all records (about 40) from my DB
next to all those results is a CHECKBOX.
What im trying to acomplish here is when a user selects 3-4 of those checkboxes next to those particular listings and hits the "ADD" button, it will ONLY add the value of YES to those specific rows.. the problem is with the code below, its updating all the rows and adding YES. The problem is its not specifing which results have the checks in them and which dont.
(FYI, i know someonw is going to suggest i change the "Name" of all my checkbox inputs, but i cant and heres why, i have a javascript running on all those results to make sure the user can ONLY select 3 boxes and not all 40. if i chnage the "Name" attribute of the checkboxes it doesnt work.)
===================================
heres my form code (stripped down to the code)
===================================
<cfoutput query="pageListings">
<img src="../#PhotoOne#" width="125" height="94"><br>
#Location#<br>
Status:#Status# </span><br>
#Bedrooms# - #Baths# - #SQFT# <br />
Price: #Price#<br />
SQFT: #SQFT#<br /><Br />
<p>MLS ID##: #listingID#<br />
<br />
Currently Featured?
<cfif #pageListings.featured# EQ "yes">
YES!
<input name="featured" type="checkbox" value="#ID#" checked />
<cfelseif #pageListings.featured# NEQ "yes">
<input name="featured" type="checkbox" value="#ID#"/>
</cfif>
<script type="text/javascript">
checkboxlimit(document.forms.EditFeature.featured, 3)
</script>
</cfoutput>
<input type="submit" name="ADD FEATURED" id="ADD FEATURED" value="ADD FEATURED" />
==========================
and heres my Action code:
=========================
<CFIF IsDefined("URL.feature")>
<!--- wipe the DB of all YES records --->
<cfquery datasource="#DSN#" name="deleteAllFeatured">
UPDATE listings
SET featured = NULL
</cfquery>
<!--- Now populate with new Featured records --->
<cfloop list="#form.featured#" index="i">
<cfquery name="insertFeat" datasource="#DSN#">
UPDATE listings
SET featured = 'Yes'
</cfquery>
</cfloop>
</cfif>
========================================
iv spent a few hours trying to find out why its updating all the records with no success.. any help would be appreciated.
I know the problem lies in the cfloop index not knowing which results had the box checked or not..
Thanks in advance..
