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

2. ColdFusion Basics > 2.7. Looping

Looping

Looping allows you to repeat specific blocks of code (both HTML and CFML) within your CFML templates. ColdFusion supports a variety of looping constructs with the <cfloop> tag, including index (for) loops, conditional (while) loops, collection loops, list loops, and query loops. For now, we are just going to cover basic index and conditional loops. Query loops are covered in Chapter 4, while collection and list loops are covered in Chapter 6.

Index Loops

Also known as a for loop, an index loop repeats a number of times specified as a range of values:

<cfloop index="index_name" from="number" to="number" step="increment">
   HTML and CFML...
</cfloop>

The index attribute of the loop specifies a variable name to hold the value corresponding to the current iteration of the loop. The


PREVIEW

                                                                          

Not a subscriber?

Start A Free Trial


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