Updating multiple values

I am trying to set all phone_display values to 1 where the #phoneid# has been passed in.  Should I be using a <cfloop> tag?  Also, I am not able to display the records from the DisplayPhoneNumbers query.  


<!--- Begin Phone number Display Section --->

<cfif isDefined("form.phone")>
<CFQUERY NAME="UpdateContact_Phone1" DATASOURCE="O2K_DEV">
UPDATE     CFUSION.CONTACT_PHONE
SET             PHONE_DISPLAY=0
WHERE       (CONTACT_ID = 125)
</CFQUERY>
</cfif>  

<cfif isDefined("form.phone")>
<CFLOOP INDEX="phoneid" LIST="#form.phone#">
<CFQUERY NAME="UpdateContact_Phone" DATASOURCE="O2K_DEV">
UPDATE     CFUSION.CONTACT_PHONE
SET             PHONE_DISPLAY=1
WHERE       (PHONE_ID = #phoneid#)
</CFQUERY>
</CFLOOP>
</cfif>  

<cfif isDefined("form.phone")>
<CFQUERY NAME="DisplayPhoneNumbers" DATASOURCE="O2K_DEV">
SELECT      CONTACT_ID, PHONE_COMMENT, PHONE_NUMBER, PHONE_DISPLAY
FROM         CFUSION.CONTACT_PHONE
WHERE       (CONTACT_ID = 125) AND (PHONE_DISPLAY = 1)
</CFQUERY>
</cfif>
<table>

<cfif isDefined("form.phone")>
<cfoutput query="DisplayPhoneNumbers">
<tr>
      <td>#DisplayPhoneNumbers.PHONE_COMMENT#</td>
      <td>#DisplayPhoneNumbers.PHONE_NUMBER#</td>
</tr>
</cfoutput>
</cfif>

<!--- begin memo display --->
jerrykovachAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

deepchandaCommented:
i would assume that the form variable #form.phone# is comma separated otherwise your <cfloop> tag will need the delimiters parameter to say whats been used to separate the phone numbers in the list. Checking the table itself from your database queying tool to see if the rows got updated would be better idea.

DC
0
jerrykovachAuthor Commented:
I agree, the specific question here is how do I loop through the update statement.  

<cfif isDefined("form.phone")>
<CFLOOP INDEX="phoneid" LIST="#form.phone#">
<CFQUERY NAME="UpdateContact_Phone" DATASOURCE="O2K_DEV">
UPDATE     CFUSION.CONTACT_PHONE
SET             PHONE_DISPLAY=1
WHERE       (PHONE_ID = #phoneid#)
</CFQUERY>
</CFLOOP>
</cfif>  

I am passing in multipe values within the #form.phone# variable.  How do I use that information to loop through the update statement?

0
Nathan Stanford SrSenior ProgrammerCommented:
So is you LIST Form.Phone a Comma Delimited List?
0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

anushaCommented:
questions is not clear. Please use an example string for what #form.phone# might have in the exact format. Do you want to make multiple updates within 1 update statement? is that the question?

Anusha
0
Nathan Stanford SrSenior ProgrammerCommented:

Is this what you are wanting?
===============================

<cfif isDefined("form.phone")>
<CFLOOP INDEX="phoneid" LIST="#form.phone#" delimiters=",">
<CFQUERY NAME="UpdateContact_Phone" DATASOURCE="O2K_DEV">
UPDATE     TableName_Here
SET             PHONE_DISPLAY=1
WHERE       (PHONE_ID = #phoneid#)
</CFQUERY>
</CFLOOP>
</cfif>  
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
jerrykovachAuthor Commented:
Nathans,

I was able to figure this one out on my own.  In the future, I will be much more specific on questons asked.  I will give you full credit on this for responding in a very timely manner again.

Jerry
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Servers

From novice to tech pro — start learning today.