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?

[Webinar] Streamline your web hosting managementRegister Today

x
 
nathansConnect With a Mentor Commented:

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
 
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
Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

 
nathansCommented:
So is you LIST Form.Phone a Comma Delimited List?
0
 
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
 
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
All Courses

From novice to tech pro — start learning today.