• Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint
Share this Page URL
Help

Chapter 7. Using Databases > Displaying Data

Displaying Data

<cfoutput> is used to resolve and display dynamic ColdFusion variables. Coupled with a query object such as the result of a <cfquery> and SELECT statement, <cfoutput> can be used to loop over results, once per record in the record set:

<cfquery name="users"
         datasource="dsn">
SELECT LastName, FirstName, Phone
FROM Users
</cfquery>

<table>
  <tr bgcolor="#cccccc">
    <th>Name</th>
    <th>Phone</th>
  </tr>
  <cfoutput query="users">
    <tr bgcolor="#IIF(users.CurrentRow MOD 2,
                     de("##ededed"),
                     de("##ffffff"))#">
      <td>#LastName#, #Firstname#</td>
      <td>#phone#</td>
    </tr>
  </cfoutput>
</table>


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


  
  • Creative Edge
  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • PrintPrint