Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Update multiple rows of informaiton

Posted on 2008-06-12
2
Medium Priority
?
273 Views
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.

Thanks,

Brian
0
Comment
Question by:brihol44
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 

Author Comment

by:brihol44
ID: 21774357
My code so far...
<cfparam name="form.pa" default="0">
<cfparam name="form.wa" default="0">
<cfparam name="form.na" default="0">
 
<cfquery name="get_advertisers" datasource="#dns#">
    SELECT * 
    FROM advertisers
    ORDER BY company_name
</cfquery>
 
<cfif isDefined("form.submit") AND form.submit EQ "submit">
    <cfloop from="1" to="#form.counter#" index="id">
            <cfquery name="update_advertisers" datasource="#dns#">
                UPDATE 
                    advertisers_ad_list
                SET  print_advertising = '#form.pa#',
                     web_advertising = '#form.wa#',
                     newsletter_advertising = '#form.na#'
                WHERE advertiser_id = '#form.advertiser_id#'
            </cfquery>
	</cfloop>
</cfif>
 
<form action="<cfoutput>#CGI.SCRIPT_NAME#</cfoutput>" method="post">
<table border="0" cellspacing="0" cellpadding="3">
  <tr>
    <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>
  </tr>
  <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" />
        </div></td>
        <td><div align="center">
          <input name="wb" type="checkbox" value="1" />
        </div></td>
        <td><div align="center">
          <input name="nl" type="checkbox" value="1" />
        </div></td>
      </tr>
  </cfoutput>
</table>
<br />
<input name="submit" type="submit" value="submit"/>

Open in new window

0
 
LVL 18

Accepted Solution

by:
Plucka earned 2000 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.
0

Featured Post

Simplify Your Workload with One Tool

How do you combat today’s intelligent hacker while managing multiple domains and platforms? By simplifying your workload with one tool. With Lunarpages hosting through Plesk Onyx, you can:

Automate SSL generation and installation with two clicks
Experience total server control

Question has a verified solution.

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

Color can increase conversions, create feelings of warmth or even incite people to get behind a cause. If you want your website to really impact site visitors, then it is vital to consider the impact color has on them.
There’s a good reason for why it’s called a homepage – it closely resembles that of a physical house and the only real difference is that it’s online. Your website’s homepage is where people come to visit you. It’s the family room of your website wh…
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
Any person in technology especially those working for big companies should at least know about the basics of web accessibility. Believe it or not there are even laws in place that require businesses to provide such means for the disabled and aging p…

715 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