checkboxes holding email addresses not working as expected

Discussion in 'Programming' started by midohioit, Sep 26, 2008.

  1. #1
    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.
     
    midohioit, Sep 26, 2008 IP
  2. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #2
    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.
     
    cfStarlight, Sep 26, 2008 IP
  3. midohioit

    midohioit Guest

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    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.
     
    midohioit, Sep 27, 2008 IP
  4. OneWebAve

    OneWebAve Peon

    Messages:
    76
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    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">)
     
    OneWebAve, Sep 28, 2008 IP
  5. midohioit

    midohioit Guest

    Messages:
    9
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    I have tried the single quote already. That did not fix things.
     
    midohioit, Sep 28, 2008 IP