No need for:
<cfset rows = Evaluate(ceiling(nLength/columns))>
or
<cfset idealrecords = Evaluate(rows * columns)>
These will do:
<cfset idealrecords = rows * columns>
<cfset rows = Ceiling(nLength / columns)>
Also, you'll produce an empty <tr></tr> at the end.
Along the same lines, this produces clean html:
<cfset cellText = "eine,meine,miney,mo,catch,developers,by,their,toe">
<cfset cols = 10>
<cfset loopTill = Ceiling(ListLen(cellText) / cols) * cols>
<cfoutput>
<table border="1">
<tr>
<cfloop from="1" to="#loopTill#" index="i">
<cfif i LTE ListLen(cellText)>
<td>#ListGetAt(cellText, i)# #i#</td>
<cfelse>
<td> </td>
</cfif>
<cfif NOT i MOD cols AND i NEQ loopTill>
</tr>
<tr>
</cfif>
</cfloop>
</tr>
</table>
</cfoutput>
Ade
-----Original Message-----
From: Mark Drew [mailto:[EMAIL PROTECTED]
Sent: 22 January 2005 12:34
To: CF-Talk
Subject: Re: Table Layout
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
--
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
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware: a new and convenient web-based time tracking application. Start
tracking and documenting hours spent on a project or with a client with Logware
today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:191435
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