Solved

cfif statment inside query

Posted on 2011-02-16
6
511 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
PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Background In several of the companies I have worked for, I noticed that corporate reporting is off loaded from the production database and done mainly on a clone database which needs to be kept up to date daily by various means, be it a logical…
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.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.

939 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

2 Experts available now in Live!

Get 1:1 Help Now