Skip to main content
Inspiring
April 3, 2008
Question

cfoutput query group

  • April 3, 2008
  • 5 replies
  • 1072 views
I have the following table, with the cfoutput, query, and group. The displayed output is below.

<center>
<table border="1" width="760">
<cfoutput query="qry" group="user_employee_number">
<tr>
<td valign="top" colspan="2"><b>#ucase(user_employee_number)#</b></td>
</tr>
<cfoutput>
<tr>
<td><a href="next_page.cfm?ref_no=#qry.ref_no#&line_item=#qry.line_item#">Reference No:#qry.ref_no#</a></td>
<td>line item #qry.line_item#</td>
</tr>
</cfoutput>
</cfoutput>
</table>
</center>

123456
Reference No: 99999 line item 1
Reference No: 99999 line item 2
345678
Reference No:00001 line item 1
912311
Reference No:10934 line item 1
Reference No:10934 line item 2
Reference No:10934 line item 3

What do I need to change so that the Reference No only shows up once, instead of occuring the same amount of times of the line item ?
    This topic has been closed for replies.

    5 replies

    Inspiring
    April 5, 2008
    Instead of this,
    ref_no line item-1
    line item-2..etc.

    Why not this?
    ref_no line
    item-1
    line item-2..etc.

    It would look a lot better and be easier to code as well.
    Inspiring
    April 4, 2008
    The reason it didn't solve your problem is that you are not displaying any data between the 2nd and 3rd cfoutput tags.

    Prasanth_Kumar_S
    Inspiring
    April 4, 2008
    Hi,
    The problem may be in the query. Are you using order by in the query?

    - Prasanth
    Inspiring
    April 4, 2008
    you can have nested groups, but since it does not seem to solve your
    problem i suspect it is your query which is to blame. it probably
    returns multiple ref_no records to start with...

    Azadi Saryev
    Sabai-dee.com
    http://www.sabai-dee.com/
    Inspiring
    April 3, 2008
    I've never actually done this, but I think you can have nested groups.

    <cfoutput group="g1">
    g1 group data
    <cfoutput group = "g2"
    g2 group data
    <cfoutput>
    more data
    </cfoutput>
    </cfoutput>
    </cfoutput>
    Inspiring
    April 3, 2008
    Just add another <cfoutput...> layer with the desired group parameter.

    <cfoutput ... group="user_employee_number">
    ...
    <cfoutput group="ref_no">
    ...
    <cfoutput>
    ...
    </cfoutput>
    ...
    </cfoutput>
    ...
    </cfoutput>
    trojnfnAuthor
    Inspiring
    April 3, 2008
    Is this where I add the other group tag ? It does not
    seem to work, still giving me duplications

    <center>
    > <table border="1" width="760">
    > <cfoutput query="qry" group="user_ employee_
    number">
    > <tr>
    > <td valign="top"
    > colspan="2"> <b>#ucase( user_employee_ number)#<
    /b></td>
    > </tr>
    <cfoutput group="ref_no" > <------
    > <cfoutput>
    > <tr>
    > <td><a
    > href="next_page. cfm?ref_no= #qry.ref_ no#&line_
    item=#qry. line_item# ">Reference
    > No:#qry.ref_ no#</a></ td>
    > <td>line item #qry.line_item# </td>
    > </tr>
    > </cfoutput>
    > </cfoutput>
    </cfoutput> <-----
    > </table>
    > </center>