Solved

cfif statment inside query

Posted on 2011-02-16
6
508 Views
Last Modified: 2012-05-11
so im looping through my query...

<cfoutput>
            <cfloop query="SQL">
<td>#Value_1#</td>
<td>#Value_2#</td>
<td>#Value_3#</td>
<td>  #Value_4#  </td>  <!-- What i want to do here is for value 5 -->
<td><cfif  #Value_4#.currentrow  = 'X'> #Value_5#  <cfelse> #Value_6#</td>
</cfif>
</tr>
</cfloop>
</cfoutput>
so I need to check Value_4 for each row to see if its X. If it is display value 5 for that row , if not display  Value 6

Please Help

0
Comment
Question by:plusone3055
6 Comments
 
LVL 19

Expert Comment

by:Jones911
Comment Utility
OK and whats failing?
0
 
LVL 1

Expert Comment

by:medsoos
Comment Utility
Try using 'is' instead of the equal (=) sign.
0
 
LVL 3

Accepted Solution

by:
sajayc earned 500 total points
Comment Utility
Hi,

Couple of things:
- You don't need the .currentrow and the closing </cfif> needs to be inside the td.
- The correct operator inside the if statement is eq for =.

Code below should work.

<cfoutput>
            <cfloop query="SQL">
<td>#Value_1#</td>
<td>#Value_2#</td>
<td>#Value_3#</td>
<td>  #Value_4#  </td>  <!-- What i want to do here is for value 5 -->
<td><cfif  Value_4 eq "X"> #Value_5# <cfelse>#Value_6#</cfif> </td>
</tr>
</cfloop>
</cfoutput>

0
IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
Get that end of table cell out of cfelse branch:

<td>
<cfif  #Value_4# EQ  'X'>
   #Value_5#  
<cfelse>
   #Value_6#
</cfif>
</td>
</tr>

And remove the .currentrow from column value in the cfif compare.

0
 
LVL 63

Expert Comment

by:Zvonko
Comment Utility
Sorry, too slow typing.
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
Comment Utility
so I need to check Value_4 for each row to see if its X. If it is display value 5 for that row , if not display  Value 6

If your value_4 and X are strings, then use compare function

<td>
<cfif NOT compareNoCase('#value_4#','X')>
	#value_5#
<cfelse>
	#value_6#
</cfif>
</td>
</tr>

Open in new window


0

Featured Post

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

How to Create User-Defined Aggregates in Oracle Before we begin creating these things, what are user-defined aggregates?  They are a feature introduced in Oracle 9i that allows a developer to create his or her own functions like "SUM", "AVG", and…
CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
This video explains at a high level about the four available data types in Oracle and how dates can be manipulated by the user to get data into and out of the database.
Video by: Steve
Using examples as well as descriptions, step through each of the common simple join types, explaining differences in syntax, differences in expected outputs and showing how the queries run along with the actual outputs based upon a simple set of dem…

744 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

15 Experts available now in Live!

Get 1:1 Help Now