PDA

View Full Version : ColdFusion help needed for <cfif>


harlequin2k5
12-11-2005, 06:49 AM
Ok- so I'm building my committees page (http://www.suncoastwebdesigns.com/test/susbcba/committees.cfm) and there is a chairperson on each committee. So what I'd like to do is have committee chair display if committeechair=yes

<cfif getfinance.CommitteeChair is "1">
<cfoutput query="getfinance">
<p>#boardofficerfirstname# #boardofficerlastname#, Committee Chair</p>
</cfoutput>
<cfelse>
<cfoutput query="getfinance">
<p>#boardofficerfirstname# #boardofficerlastname#</p>
</cfoutput>
</cfif>


while the syntax of this piece is correct - it displays "committee chair" next to each name - I would like for that phrase to show for only the committee chair - which in this case would be Ron Averbeck

Any thoughts or am I just being stupid? :D I was thinking that I need to create separate queries for that type of output but before I went through all of that I thought I'd ask first - I can't seem to find any help through macromedia or my cf book

oracleguy
12-12-2005, 03:19 AM
I also agree that the code looks correct, what I'd suggest you try is to see what the value of comitteechair is. Maybe its outputting 1 all the time or some weird data. So maybe try:


<cfoutput query="getfinance"><p>#ComitteeChair#</p></cfoutput>
<cfif getfinance.CommitteeChair is "1">
<cfoutput query="getfinance">
<p>#boardofficerfirstname# #boardofficerlastname#, Committee Chair</p>
</cfoutput>
<cfelse>
<cfoutput query="getfinance">
<p>#boardofficerfirstname# #boardofficerlastname#</p>
</cfoutput>
</cfif>


Just so you can see what it is actually comparing to.

Edit: Oooh one other thought, maybe try: is 1 instead of: is "1" if that column is indeed a number, maybe that is causing the logic error.

SteelValor
12-12-2005, 04:59 PM
<cfoutput query="getfinance">
<p>#boardofficerfirstname# #boardofficerlastname#<cfif getfinance.CommitteeChair eq 1>Committee Chair</cfif></p>
</cfoutput>


This should work for you :D

harlequin2k5
12-13-2005, 07:42 AM
that worked perfect!!

thanks so much SV!!

SteelValor
12-13-2005, 02:07 PM
np :D