Solved

cfif statment inside query

Posted on 2011-02-16
6
513 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
ID: 34912851
OK and whats failing?
0
 
LVL 1

Expert Comment

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

Accepted Solution

by:
sajayc earned 500 total points
ID: 34913021
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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 63

Expert Comment

by:Zvonko
ID: 34913029
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
ID: 34913034
Sorry, too slow typing.
0
 
LVL 11

Expert Comment

by:Brijesh Chauhan
ID: 34913467
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Oracle SQL syntax check  without executing 6 56
Oracle 12c database link between pdb not working 20 80
SQL Developer 6 49
Trying to get a Linked Server to Oracle DB working 21 60
Hi, Even though I have created this Tutorial on My personal Blog, Some people might not able to find my website, So here i am posting it again Today, from the topic it is very clear that i will be showing you here the very basic usage of how we …
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 shows how to configure and send email from and Oracle database using both UTL_SMTP and UTL_MAIL, as well as comparing UTL_SMTP to a manual SMTP conversation with a mail server.
This video explains what a user managed backup is and shows how to take one, providing a couple of simple example scripts.

803 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