Using Looping

Loops are another fundamental language element supported by most development platforms. Loops do just that—they loop. Loops provide a mechanism with which to repeat tasks, and ColdFusion supports several types of loops, all via the <cfloop> tag:

  • Index loops, used to repeat a set number of times

  • Conditional loops, used to repeat until a specified condition becomes FALSE

  • Query loops, used to iterate through database query results

  • List loops, used to iterate through a specified list

  • Collection loops, used to loop through structures

  • File loops, used to loop through the lines in a file

You won’t use all these loop types here, but to acquaint you with <cfloop>, let’s look at a few examples.

Get Adobe ColdFusion 8 Web Application Construction Kit, Volume 1: Getting Started now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.