Skip to main content
Participant
January 30, 2009
Question

CFLOOP a CFINSERT

  • January 30, 2009
  • 1 reply
  • 557 views
I have created a emailer and you can add up to 8 different recipeints. I am trying to insert the recipeints name in a databse in there own row.

I can not figure out how to cfloop my cfinsert to do this. I got to the point where it adds all the recipeints into 8 rows.

Here is my code:

<cfloop index="idx" list="#form.cemail#">
<cfinsert datasource="emailer" tablename="VAprevention">

<cfmail to="#idx#" from="#form.remail#" subject="#form.subject#" cc="#form.remail#" type="html">

</cfmail>
</cfloop>
    This topic has been closed for replies.

    1 reply

    Inspiring
    January 30, 2009
    CFINSERT is intended to insert a single row based on data from a form. Since you need to do several inserts replace CFINSERT with CFQUERY.
    Participant
    January 30, 2009
    Thanks for you help Bob.

    I was wondering if you could help me with one more part. When i am using th CFloop I need to insert the nam and email of who i am sending the email to. How do I use both of these values as my "list"

    I hope that makes sense

    <cfloop index="idx" list="#form.cemail# and #form.cname#"> <!----- This is where i am stuck ----->
    <cfquery name="mailer" datasource="emailer">
    INSERT INTO VAprevention
    (mdate,
    cemail,
    cname,
    remail,
    rname,
    rnumber,
    message,
    subject)
    VALUES (#mdate#,
    '#form.cemail#',
    '#form.remail#',
    '#form.cname#',
    '#form.rname#',
    '#form.rnumber#',
    '#form.message#',
    '#form.subject#')
    </cfquery>

    <cfmail to="#idx1#" from="#form.remail#" subject="#form.subject#" cc="#form.remail#" type="html"> Text
    Inspiring
    January 30, 2009
    kricktru08,

    Can you post your complete code? If not can you post a sample of the contents of the form variables you are using in your code?