Skip to main content
Known Participant
November 11, 2011
Question

Query to bulleted list

  • November 11, 2011
  • 1 reply
  • 964 views

I have a query that returns 31 results.  The db is set up with a file name, url, membership, submembership.  I want to create a bulleted list from the 31 records in the following manner

1

  • item1
  • item2

2

  • item1
  • item2

3

  • item1
  • item2
    • subitem1
    • subitem2

4

  • item1
  • item2

The question is ... the best way to do this.  Is it easier to loop through the query and crete an array for each item?    Thanks.

    This topic has been closed for replies.

    1 reply

    Inspiring
    November 11, 2011

    The group attribute of cfoutput should work.

    Known Participant
    November 11, 2011

    I dont see how that would work right.  If i use

    <cfoutput query="healthyliving" group="membership">

         <li>#title#</li>   

    </cfoutput>

    I only get like 3 items. 

    membership is, in the example, 1, 2, or 3 etc.  The submembership is the subitem1 etc.  I dont see how the grouping would work right.  Do you have a code example?

    Inspiring
    November 11, 2011

    There is a code example in the documentation, but it does not mention that you can have nested grouping.  Something like this:

    <cfoutput query="xxx" group="field1">

    #data grouped at this level#

    <cfoutput group="field2">

    #data grouped at this level#

    <cfoutupt>

    #ungrouped data#

    closing tags.

    Make sure your query has an order by clause that coincides with the way you want to group your output.  For my example, it would be:

    select etc

    order by field1, field2