How to output table results by using cfoutput group by date?

依然范特西╮ 提交于 2019-11-30 09:49:26

问题


I have a query that get the all the employees count in a table:

emp_namelast | emp_namefirst | employeetotal | year_cse1
--------------------------------------------------------
smith        | john          | 13            | 2014
smith jr     | jonnny        | 10            |2014
baker        |jane           |5              |2015
doe           |john           |6             |2015

I'm outputting the results in a table. I have the results in order from the query. But with the code below it's outputting the top result from 2014 and then the top result from 2015.

I have tried using no group , which gives me all the data from the query. I would like it to output the data from 2014 and 2015 in two different tables. One would contain records for 2014 and the other 2015.

Would it have to be done without using a 'group'?

<h2>employees</h2>

<table >
    <thead><tr><th>Employee</th><th>Stars</th></tr></thead>
    <tbody> 
        <cfoutput query="GetEmployeeTotals" group="year_cse1">  
            <tr><td>#emp_namefirst# #emp_namelast#</td>
                <td>#employeetotal#</td>
            </tr>   
        </cfoutput>
    </tbody>
</table>

回答1:


You are on the right track but are missing a detail. The group attribute works like this:

<cfoutput query="somequery" group="somefield">
grouped data goes here

<cfoutput>
ungrouped data goes here
</cfoutput>
grouped data can go here as well
</cfoutput>

In your code, you are not outputting any grouped data, and you are missing the extra cfoutput tags for the ungrouped data.



来源:https://stackoverflow.com/questions/24147088/how-to-output-table-results-by-using-cfoutput-group-by-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!