Looping Over A List - MACROMEDIA COLDFUSION 4.5-CFML LANGUAGE Reference

Cfml language reference
Table of Contents

Advertisement

132
The following example loops from the tenth through the twentieth record returned by
"MyQuery ":
<CFSET Start=10>
<CFSET End=20>
<CFLOOP QUERY="MyQuery"
STARTROW="#Start#"
ENDROW="#End#">
<CFOUTPUT>#MyQuery.MyColName#</CFOUTPUT><BR>
</CFLOOP>
The loop is done when there are no more records or when the current record is greater
than the value of the ENDROW attribute.
Example 3
The advantage of looping over a query is that you can use CFML tags that are not
allowed in a CFOUTPUT. The following example combines the pages returned by a
query of a list of page names into a single document using the
<CFQUERY NAME="GetTemplate"
DATASOURCE="Library"
MAXROWS="5">
SELECT TemplateName FROM Templates
</CFQUERY>
<CFLOOP QUERY="TemplateName">
<CFINCLUDE TEMPLATE="#TemplateName#">
</CFLOOP>

Looping over a List

Looping over a list offers the option of walking through elements contained within a
variable or value returned from an expression. In a list loop, the INDEX attribute
specifies the name of a variable to receive the next element of the list, and the LIST
attribute holds a list or a variable containing a list.
Syntax
<CFLOOP INDEX="index_name"
LIST="list_items"
DELIMITERS="item_delimiter">
</CFLOOP>
INDEX
Required. In a list loop, the INDEX attribute specifies the name of a variable to
receive the next element of the list, and the LIST attribute holds a list or a variable
containing a list.
LIST
Required. The list items in the loop, provided directly or with a variable.
CFML Language Reference
CFINCLUDE
tag.

Advertisement

Table of Contents
loading
Need help?

Need help?

Do you have a question about the COLDFUSION 4.5-CFML LANGUAGE and is the answer not in the manual?

Questions and answers

This manual is also suitable for:

Coldfusion 4.5

Table of Contents