I was wondering if this could be done or not... on a form I have checkboxes next to some email addresses going through a loop by a query. The check box looks like this: <cfinput type="checkbox" name="chk_email" value= '<cfoutput>#getclients.email#</cfoutput>' /> Code (markup): my sql query looks like this: delete from #guests# where email in(#form.chk_email#) Code (markup): But I get the error: I noticed that when selected more then one value (checkbox) that it automatically puts a comma between a value. this is perfect for a "in" query but is there a way on the actual checkbox line that I can put a single quote (') around the cfoutput tags to get this result: delete from #guests# where email in ('email1@email.com', 'email2@email.com') Code (markup): I have tried already: <cfinput type="checkbox" name="chk_email" value= "<cfoutput>[COLOR="Red"]'[/COLOR]#getclients.email#[COLOR="Red"]'[/COLOR]</cfoutput>" /> Code (markup): Thinking that would do the trick but I get cf errors. Please help me... Thanks in advanced.
Yes, when multiple checkboxes have the same "name". Use <cfqueryparam list="true" cfsqltype="cf_sql_varchar" value="#yourformfield#">. Then you do not have to worry about quotes.
first of all, thank you for your help. It is not acually removing the records from the database. I was wondering if you could help me figure out why, it is confusing me and I dont see it, maybe another pair of eyes would help. Here is the new code: <cfquery name="delclients" datasource="newsletter"> delete from #guests# where email in (<cfqueryparam value="#form.chk_email#" list="true" cfsqltype="cf_sql_varchar">) </cfquery> <cfoutput>delete from #guests# where email in(#form.chk_email#)</cfoutput> Code (markup): Here is the output from the <cfoutput> tags: It says it completed but it does not remove the records. It is accessing a mysql database.
You may want to try putting single quotes around the email addresses, like this: delete from #guests# where email in (<cfqueryparam value="'#form.chk_email#'" list="true" cfsqltype="cf_sql_varchar">)