Reading Data from an Array

Just as with structures, there are lots of ways to reference specific data packaged in an array. The most basic method is to refer to a specific row and column number, like this:

<CFOUTPUT>
#movies[2][2]#
</CFOUTPUT>

This would cause ColdFusion to output the text "1957," which appears in the second column of the second row of my database table, and also in my array #movies#.

If I want to display all the data stored in an array, I can also use the <CFLOOP> tag, as illustrated in Listing 15.9.

Listing 15.9 Populating and Displaying an Array
 1: <!---GET TITLE, YEAR FOR ALL MOVIES---> 2: 3: <CFQUERY name="get_movies" datasource="elvis"> 4: SELECT title, year from movies 5: </CFQUERY> 6: <!---CREATE A NEW ARRAY CALLED ...

Get Sams Teach Yourself ColdFusion® in 21 Days 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.