I suppose this is on IE? I wouldn't try that on another browser (HTML
not valid). Also you need to take empty cells into account at the end of
the table (if there are only nine records for example).

This code will work with any number of columns in the table and any
number of records in your query:

<!--- number of columns --->
<cfset n = 2>
<!--- Empty cells at the end --->
<cfset remainingCells = (n - qTest.recordCount MOD n) MOD n>
<cfif qTest.recordCount>
<table border="1">
<cfoutput query="qTest">
<cfif qTest.currentRow MOD n IS 1>
<tr>
</cfif>
<td>#qTest.title#</td>
<cfif qTest.currentRow MOD n IS 0>
</tr>
</cfif>
</cfoutput>
<cfif remainingCells>
<cfloop from="1" to="#remainingCells#" index="i">
<td>&nbsp;</td>
</cfloop>
</tr>
</cfif>
</table>
</cfif>

Pascal

> -----Original Message-----
> From: Greg Luce [mailto:[EMAIL PROTECTED]
> Sent: donderdag 1 april 2004 18:36
> To: CF-Talk
> Subject: RE: CFOUTPUT Question
>
> Bruce,
> I just ran this against a local table and it renders 2
> nice columns. The "y" helps you see what currentrow MOD 2 is doing.
> <cfquery name="x" datasource="cftest">
>   SELECT TOP 10 *
>   FROM company
> </cfquery>
> <table width="90%" border="1">
>   <tr>
>   <cfoutput query="x">
>     <cfset y = CurrentRow Mod 2>
>     <td>#email# - #y#</td>
>     <cfif CurrentRow Mod 2 LT 1>
>        </tr>
>        <tr>
>        </tr>
>     </cfif>
>   </cfoutput>
> </table>
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

Reply via email to