# CFOUTPUT

Displays the results of a database query or other operation. If you need to nest CFOUTPUT tags, please read the "Usage" section.

### Syntax

    <CFOUTPUT
        QUERY="query_name"
        GROUP="query_column"
        GROUPCASESENSITIVE="yes/no"
        STARTROW="start_row"
        MAXROWS="max_rows_output">

    </CFOUTPUT>

#### QUERY

Optional. The name of the CFQUERY from which you want to draw data for the output section.

#### GROUP

Optional. Specifies the query column to use when you group sets of records together. Use this attribute if you have retrieved a record set ordered on a certain query column. For example, if you have a record set that is ordered according to "Customer_ID" in the CFQUERY tag, you can group the output on "Customer_ID." The GROUP attribute, which is case sensitive, eliminates adjacent duplicates in the case where the data is sorted by the specified field. See the GROUPCASESENSITIVE attribute for information about specifying a case insensitive grouping.

#### GROUPCASESENSITIVE

Optional. Boolean indicating whether to group with regard to case or not. The default value is YES; case is considered while grouping. If the QUERY attribute specifies a query object that was generated by a case-insensitive SQL query, set the GROUPCASESENSITIVE attribute to NO to keep the recordset intact.

#### STARTROW

Optional. Specifies the row from which to start output.

#### MAXROWS

Optional. Specifies the maximum number of rows you want displayed in the output section.

### Usage

In order to nest CFOUTPUT blocks, you must specify the GROUP and QUERY attributes at the top-most level, and the GROUP attribute for all inner blocks except for the inner-most CFOUTPUT block.

### Example

    <!--- This example shows how CFOUTPUT operates --->

    <!--- run a sample query --->
    <CFQUERY NAME="GetCourses" DATASOURCE="cfsnippets">
    SELECT Dept_ID, CorName, CorLevel
    FROM courseList
    ORDER by Dept_ID, CorLevel, CorName

    </CFQUERY>
    <HTML>
    <HEAD>
    <TITLE>CFOUTPUT</TITLE>
    </HEAD>
    <BODY>
    <H3>CFOUTPUT Example</H3>

    <P>CFOUTPUT simply tells ColdFusion Server
    to begin processing, and then to hand back control
    of page rendering to the web server.

    <P>For example, to show today's date, you could write
    #DateFormat("#Now()#").  If you enclosed that expression
    in CFOUTPUT, the result would be <CFOUTPUT>#DateFormat(Now())#
      </CFOUTPUT>.

    <P>In addition, CFOUTPUT may be used to show the results of
    a query operation, or only a partial result, as shown:

    <P>There are <CFOUTPUT>#getCourses.recordCount#</CFOUTPUT> total records
    in our query.  Using the MAXROWS parameter, we are limiting our
    display to 4 rows.
    <P>
    <CFOUTPUT QUERY="GetCourses" MAXROWS=4>
    <PRE>#Dept_ID#    #CorName#    #CorLevel#</PRE>

    </CFOUTPUT>

    <P>CFOUTPUT can also show the results of a more complex expression,
    such as getting the day of the week from today's date.  We first
    extract the integer representing the Day of the Week from
    the server function Now() and then apply the result to
    the DayofWeekAsString function:

    <BR>Today is #DayofWeekAsString(DayofWeek(Now()))#
    <BR>Today is <CFOUTPUT>#DayofWeekAsString(DayofWeek(Now()))#</CFOUTPUT>

    <P>
    </BODY>
    </HTML>