coldfusioncfwheels

ColdFusion Query Loop Next Value


Hello I have query array with values

now I have to display this array in the following manner

cat_1

cat_2

cat_3

I have using a table with associations to get join data from categories and item tables but when I output it to my view. I am not sure how to get the next value of the row in the query loop.

<cfloop query="checklist">
#checklist.categoriesname# #checklist.name#
</cfloop>

Above is my current loop, I want to get the categoriesname once and if is the same as last not output it.


Solution

  • As suggested above, code resolve the issue for me.

    <cfloop query="checklist" group="categoriesname">
    #checklist.categoriesname#
    <cfloop>
    #checklist.name#
    </cfloop>
    </cfloop>