Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cfif inside loop through columns for table headings not working

I'm new here so forgive me for all the formatting errors. I'm trying all the help topics...

Using coldfusion, I'm trying to display all columns in a table heading except for 2 of them. They all show up. I'm not sure what I'm doing wrong.

<cfloop list="#ArrayToList(getTableDataHeading.getColumnNames())#"index="col" >
    <cfif "#col#" NEQ "itemID" or "#col#" NEQ "locationID">
        <th>#col#</th>
    </cfif>
</cfloop>
like image 463
malibu65k Avatar asked Nov 29 '25 16:11

malibu65k


1 Answers

You are using wrong condition in your cfif statement. You need AND condition and not the OR condition. Learn how operators work here.

<cfoutput>
    <cfloop list="#ArrayToList(getTableDataHeading.getColumnNames())#"index="col" >
       <cfif col NEQ "itemID" AND col NEQ "locationID">
          <th>#col#</th>
       </cfif>
   </cfloop>
</cfoutput>

You should also try to avoid unnecessary use of # sign. Check out the difference between your cfif statement and mine regarding the use of # sign.

like image 97
Tushar Bhaware Avatar answered Dec 02 '25 07:12

Tushar Bhaware



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!