Update multiple rows of informaiton

Posted on 2008-06-12
Last Modified: 2013-11-19
I'm needing help in understanding how to update x amount of rows of data with 3 check boxes for each row. I know how to do this with one set of check boxes but can't seem to figure out multiple boxes.

The check boxes have a value of 1 in them.


Question by:brihol44

Author Comment

ID: 21774357
My code so far...
<cfparam name="" default="0">

<cfparam name="form.wa" default="0">

<cfparam name="" default="0">

<cfquery name="get_advertisers" datasource="#dns#">

    SELECT * 

    FROM advertisers

    ORDER BY company_name


<cfif isDefined("form.submit") AND form.submit EQ "submit">

    <cfloop from="1" to="#form.counter#" index="id">

            <cfquery name="update_advertisers" datasource="#dns#">



                SET  print_advertising = '',

                     web_advertising = '#form.wa#',

                     newsletter_advertising = ''

                WHERE advertiser_id = '#form.advertiser_id#'




<form action="<cfoutput>#CGI.SCRIPT_NAME#</cfoutput>" method="post">

<table border="0" cellspacing="0" cellpadding="3">


    <td width="351">Company Name</td>

    <td width="61" nowrap="nowrap"><div align="center">Print Ad</div></td>

    <td width="88" nowrap="nowrap"><div align="center">Web Banner</div></td>

    <td width="81" nowrap="nowrap"><div align="center">Newsletter</div></td>


  <cfoutput query="get_advertisers">

      <tr bgcolor="###iif(currentrow MOD 2,DE('ffffff'),DE('efefef'))#">

        <td><input name="form.advertiser_id" type="field" value="#get_advertisers.advertiser_id#" />#get_advertisers.company_name#</td>

        <td><div align="center">

          <input name="pa" type="checkbox" value="1" />


        <td><div align="center">

          <input name="wb" type="checkbox" value="1" />


        <td><div align="center">

          <input name="nl" type="checkbox" value="1" />





<br />

<input name="submit" type="submit" value="submit"/>

Open in new window

LVL 18

Accepted Solution

Plucka earned 500 total points
ID: 21775038
Im not sure I understand the problem.

There are two ways to update multiple records.

1. Do Multiple Updates, ie loop over your logic and do an update for each iteration of loop
2. Update with a where, where all matching records would be updated in one hit. IE update table where category="y' all records with category Y would be updated.

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Developer portfolios can be a bit of an enigma—how do you present yourself to employers without burying them in lines of code?  A modern portfolio is more than just work samples, it’s also a statement of how you work.
This video teaches users how to migrate an existing Wordpress website to a new domain.
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now