On 12/23/00, Barney Stevenson penned:
>There is probably a really obvious answer to this, but I can't work out
>how to display records in multiple columns.
>
>I want to achieve something like this:
>
><tr><td>record 1</td><td>record 2</td></tr>
><tr><td>record 3</td><td>record 4</td></tr>
><tr><td>record 5</td><td>record 6</td></tr>
>etc.
>
>So that my query results are displayed in balanced columns

Here is your best bet. You can set the cols variable to whatever you 
want. If there are any cells remaining, such as if you used 2 like 
you want and have 11 records, it will place a blank cell in the last 
row. If you set cols to 3 and have 7 items, there will be two blank 
cells in the last row, etc., etc.  Archive this code for the future. 
LOL

<cfset cols = 2>
<cfset extracells = evaluate(cols - (myQuery.recordcount MOD cols))>

<table border = 1>
<tr>
<CFOUTPUT query="myQuery"><td>#myOutput#</td>
<CFIF currentrow MOD cols IS "0"></tr><CFIF currentrow LT recordcount>
<tr></CFIF>
</CFIF></CFOUTPUT><CFIF extracells LT cols><cfloop index="noindex" 
from="1" to="#extracells#"><td>&nbsp;</td>
</cfloop></tr></CFIF>
</table>
-- 

Bud Schneehagen - Tropical Web Creations

_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/_/
ColdFusion Solutions / eCommerce Development
[EMAIL PROTECTED]
http://www.twcreations.com/
954.721.3452

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
        Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to