Outputting Database Data

Contact Us or call 1-877-932-8228
Outputting Database Data

Outputting Database Data

We have used <cfquery> to check for the existence of a record and to insert a new record. It is also often used to select a group of records, known as a recordset, and output them to the web page. The most common way to output the data is to use the <cfoutput> tag with its query attribute set to the relevant query name. The following example illustrates this.

Code Sample:

DatabaseBasics/Demos/cfoutput.cfm
<cfquery name="getUsers" datasource="#APPLICATION.datasource#">
	SELECT firstname, lastname, email
	FROM Users
</cfquery>

<html>
<head>
<title>Using cfoutput</title>
</head>
<body>
<ul>
<cfoutput query="getUsers">
	<li>#firstname#	#lastname# (#email#)</li>
</cfoutput>
</ul>
</body>
</html>

The output of this page is shown below:

Next