> Hi all -- > > I would like to display the rows of a data table as columns. Is that > doable with ColdFusion? > > Scott
Hi Scott If I understand correctly you are trying to output the table in columns I.e Output 4 columns start a new row and display only 20 records per page. Outputting columns not rows requires a little more work than normal, the main difference is that your be placing your cfoutput query tags before the <td> not <tr>. You also need to count the columns and at every fourth column start a new row. Please see below some code, on how I achieved this, <!---//Set the new row variable to false---> <cfset Variables.newrow = false> <table width="100%" border="0" cellspacing="0" cellpadding="0"> <tr> <!---//this will count our rows---> <cfset Variables.iCounter =1> <cfoutput query="yourQuery"> <!---//set variables newrow to true---> <cfif Variables.newrow EQ 'true'> <tr> </cfif> <td valign="top">#yourQueryData# </td> <!---//we use the mod operator to see if the current record being output is evenly divisible by 4 if it is start a <tr>, if not place a</tr> since we only want 4 columns per row---> <cfif Variables.iCounter MOD 4 EQ 0> </tr> <cfset Variables.newrow = 'true'> <cfelse> <cfset Variables.newrow = 'false'> </cfif> <cfset Variables.iCounter = (Variables.iCounter + 1) /><!--- Added - increment the row counter ---> </cfoutput> </tr> </table></td> I use and modified this code from http://tutorial140.easycfm.com/ quite a good tutorial. hope this helps. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;203748912;27390454;j Archive: http://www.houseoffusion.com/groups/CF-Newbie/message.cfm/messageid:4007 Subscription: http://www.houseoffusion.com/groups/CF-Newbie/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.15
