Here is a sample I did with a list, I am sure you can re-purpose it for a query
I have added comments so you know
//We set a list of words we are going to loop over
<cfset lWords = "eine, meine, miney, mo, catch, developers, by, their, toe">
<cfset nLength = ListLen(lWords)>
//The number of columns we want (this is a word and spacer)
<cfset columns = 4>
//Now, we check how many rows there would be , I do a ceiling function
so that I get the upper integer e.g.
//if we have 9 items, and we have 4 columns, we shall have 3 rows, the
last row having one item and 3 blanks
<cfset rows = Evaluate(ceiling(nLength/columns))>
//the ideal number of records that we shall have in TOTAL (including
empty ones) in the table
<cfset idealrecords = Evaluate(rows * columns)>
<cfoutput>
Number of items = #nLength#<br />
Number of columns = #columns# <br />
Number of Rows = #rows#<br />
Ideal Number of Columns = #idealcols#<br />
<table border="1">
<tr>
//Loop from 1 to the ideal total number of items (never mind rows)
<cfloop from="1" to="#idealcols#" index="i">
//We set if this column needs a row
<cfset colCounter = i MOD columns>
//make sure that we dont need an empty space
<cfif i LTE ListLen(lWords)>
<td>#ListGetAt(lWords, i)# #colCounter#</td>
<cfelse>
<td> </td>
</cfif>
//Insert a row if required
<cfif colCounter EQ 0>
</tr>
<tr>
<cfelse>
<td> </td>
</cfif>
</cfloop>
</tr>
</table>
</cfoutput>
This should get you started, I am sure you can condense this but I
made it verbose so you could understand it
I shall try something with a query for you to use but otherwise you
could use ValueList(your query.column) and achieve the same effect
Regards
Mark Drew
On Sat, 22 Jan 2005 11:46:18 -0000, Adrian Lynch
<[EMAIL PROTECTED]> wrote:
> I think this will produce dodgy html. If the query is less than 4 you'll
> never get the closing </tr>. Also, if the record count is not a multiple of
> 4 then you'll have a different number of <td></td> in the last row.
>
> Of the top of my head, to fix the first problem, use this:
>
> <cfif getSpecials.CurrentRow MOD 4 EQ 0 OR getSpecials.CurrentRow EQ
> getSpecials.RecordCount>
>
> instead of just:
>
> <cfif getSpecials.currentRow MOD 4 eq 0>
>
> To fix the second problem of padding out the last row with extra cells if it
> needs it, try something like this:
>
> <cfif getSpecials.CurrentRow MOD 4 EQ 0 OR getSpecials.CurrentRow EQ
> getSpecials.RecordCount>
> <cfloop from="1" to="#getSpecials.CurrentRow MOD 4#" index="i">
> <td> </td>
> </cfloop>
> <tr>
> </cfif>
>
> Again that's just thinking quickly, it may be buggy.
>
> Ade
>
> -----Original Message-----
> From: Eric Creese [mailto:[EMAIL PROTECTED]
> Sent: 20 January 2005 16:55
> To: CF-Talk
> Subject: RE: Table Layout
>
> Here is a little thing I do but the empty cell part I do not have.
>
> <table>
> <tr>
> <cfoutput query="getSpecials">
> <td width="130" valign="top">
> <center><img src="images/products/#largeimage#"
> border="0"></center>
> </td>
> <cfif getSpecials.currentRow MOD 4 eq 0>
> </tr>
> </cfif>
> </cfoutput>
> </table>
> --
> No virus found in this outgoing message.
> Checked by AVG Anti-Virus.
> Version: 7.0.300 / Virus Database: 265.7.2 - Release Date: 21/01/2005
>
>
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Discover CFTicket - The leading ColdFusion Help Desk and Trouble
Ticket application
http://www.houseoffusion.com/banners/view.cfm?bannerid=48
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:191433
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54