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:

<cfquery name="getUsers" datasource="#APPLICATION.datasource#">
	SELECT firstname, lastname, email
	FROM Users

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

The output of this page is shown below: