Skip to main content
September 24, 2013
Question

Outputing a query

  • September 24, 2013
  • 1 reply
  • 395 views

I thought I used to be able to do this but since I have not done it for awhile I forgot how to do it.

I have a query result that looks like this:

Categories    Course_Name  Course_No  Course_level

Language     English             E100001        Intro

Language     English             E20001        Intermediate

Language     English             E30001        Advance

Language     Spanish           S10001        Intro

Language     Spanish           S20001        Intermediate

Language     Spanish           S30001        Advance

Art                 Piano               P11001       Intorduction

Art                 Piano               P21001       Intermediate

Art                 Piano               P31001       Advance

I need to output this query in a table so when user look at this table, category will only showed once:

Categories    Course_Name  Course_No  Course_level

Language     English             E100001        Intro

                     English             E20001        Intermediate

                     English             E30001        Advance

                     Spanish           S10001        Intro

                     Spanish           S20001        Intermediate

                     Spanish           S30001        Advance

Art                 Piano               P11001       Intorduction

                     Piano               P21001       Intermediate

                     Piano               P31001       Advance

I used table but I can' get it  right, can anyone help, thank you!!

<table>

  <tr>

     <td>Category</td>

     <td>Course Name</td>

     <td>Course Number</td>

     <td>Course Level</td>

   </tr>

  <cfquery name="GetCourses datasource="#dsn#">

   select * from program 

   order by category

  </cfquery>

<cfoutput query="GetCourses">

  <cfquery name="GetCategory datasource="#dsn#">

   select distinct categorry from program

  </cfquery>

  <tr>

     <td>#GetCategory.Category#</td>

     <td>#Course_Name#</td>

     <td>#Course Number#</td>

     <td>#Course Level#</td>

   </tr>

</cfquery>    

</table>

This topic has been closed for replies.

1 reply

p_sim
Participating Frequently
September 25, 2013

<cfoutput query="GetCourses" group="Categories">

     #Categories#

     <cfoutput>

          #Course_Name# #Course_No# #Course_Level#

     </cfoutput>

</cfoutput>