The School for Champions is an educational website that shows you how to achieve your dreams.
![]() |
|
|
SfC Home > ColdFusion > Explanation of how to populate a complex matrix table using the Macromedia ColdFusion markup language. Also refer to database, SQL, query, format, CFLOOP, loop, maximum rows, Ron Kurtus, School for Champions. Copyright © Restrictions Populating a Matrix Table with ColdFusionby Ron Kurtus (26 December 2002) Taking information from a database and linearly populating the rows of a table is relatively simple in Macromedia ColdFusion. It is more difficult to populate a table that is a matrix, with both columns and rows. The method is similar to populating a simple table, except that you, must define the number of rows and then loop through the matrix. Questions you may have include:
This lesson will answer those questions. There is a mini-quiz near the end of the lesson. Simple tableThe method to simply populate the rows of a table in a given sequence is: <CFQUERY NAME="list" DATASOURCE="xyz" DBTYPE="ODBC"> <TABLE> This is pretty straightforward. Populate matrixTo populate a matrix table of 3 columns by a number of rows determined by the amount of data you have, you first make the same query as in the simple case. The data in this table is ordered by a sequence number. You could also order the data by ID value. <CFQUERY NAME="list" DATASOURCE="xyz" DBTYPE="ODBC"> Define number of rowsFind the number of records in your table. Then set the maximum rows as the integer of the number of records + 2, divided by 3. If the number of columns was 5, the maximum rows would be the integer of the number of records + 4, divided by 5. <CFSET max_seq = #set_count.recordcount#> Loop through matrixFirst set a variable x = 0. Loop through the number of rows and then the columns. <CFSET x = 0> <TABLE> OutputThe output table would look something like:
This is an example where the maximum rows is the integer of (7 + 2)/3 = 3 SummaryYou can populate a table that is a matrix, with both columns and rows, by defining the maximum number of rows, looping through the rows, plus looping through the columns for each row. Maintain a healthy attitude toward your work ResourcesThe following resources provide information on this subject. WebsitesBooksMiscellaneousMini-quiz to check your understanding1. What is ColdFusion Studio? 2. What is needed to display ColdFusion pages on the Web? 3. What is a major application of ColdFusion? If you got all three correct, you are on your way to becoming a Champion in ColdFusion Development. If you had problems, you had better look over the material again. What do you think?Do you have any questions, comments, or opinions on this subject? If so, send an email with your feedback. We will try to get back to you as soon as possible. Share linkFeel free to establish a link from your website to pages in this site. Or use our form to send this link to yourself or a friend. Students and researchersThe Web address of this page is Where can you go from here?
|
The School for Champions helps you become the type of person that can be can be called a Champion.