i use this for my image galleries all the time
<table border="0" cellpadding="0" cellspacing="0">
<tr>
<td>
<cfloop query="queryname">
#queryfield#
</td>
<!--- if its the 3rd column or last record, close the row --->
<cfif currentrow MOD 3 is 0 or currentrow is recordcount>
</tr>
<!--- if it is not the end of the records, start a new row --->
<cfif currentrow NEQ recordcount>
<tr>
<td>
</cfif>
<cfelse>
<td>
</cfif>
</cfloop>
</table>
just wrote that out, looks right though : )
of course this is assuming you want to go left to right 3 records then go to
the next row for the next 3 records left to right
1 2 3
4 5 6
7 8 9
10 11 12
to display
1 6 11
2 7 12
3 8 13
4 9 14
5 10 15
<!---get the recordcount and divide by 3 (columns) --->
<cfset columnonecount = round(gettotal.recordcount/3)>
<cfset columntwocount = round(gettotal.recordcount/3)>
<cfset columnthreecount = round(gettotal.recordcount/3)>
<!--- now you have three equal column counts, set any remainders to a
variable and add it to what ever column you want the extra 1 or 2 records to
be in -->
<cfset leftovers = gettotal.recordcount MOD 3>
<!--- lets put them in one and two (assuming we had 2 remainder) --->
<cfif leftovers GT 0>
<cfset columnonecount = columnonecount + 1>
</cfif>
<cfif leftovers GT 1>
<cfset columntwocount = columntwocount + 1>
</cfif>
<!--- now start your loop for the first column --->
<cfoutput>
<table border="0" cellpadding="10" cellspacing="0">
<tr>
<td>
<cfloop query="queryname">
#field#<br>
<!--- this is only possible once and it will be in the first column --->
<cfif currentrow is columnonecount>
</td><td>
</cfif>
<!--- this is only possible once as well and will only be in the second
column --->
<cfif currentrow GT columnonecount and currentrow LT columnThreeCount and
currentrow EQ columntwocount>
</td><td>
</cfif>
</cfloop>
<!--- the next </td></tr> automatically closes the 3rd column and ends the
row when all records are out --->
</td>
</tr>
</table>
</cfoutput>
again, off the top off my head...and im sure full of typos. Ive only had to
do the second method once for a dynamic client list of two columns that had
to be in the right order...but three should work just as well
----- Original Message -----
From: "Nathan Mische" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, February 21, 2003 12:23 PM
Subject: 3 Cells Wide
> Hey Guy,
>
> This is what I came up with:
>
>
> <cfquery name="queryName" datasource="datasourceName">
> SELECT c.categoryName, s.subCategoryName
> FROM tblCategory c, tblSubCategory s
> WHERE c.categoryid = s.categoryid
> ORDER BY c.categoryName
> </cfquery>
>
> <cfset categoryCount=1>
> <table>
> <tr>
> <cfoutput query="queryName" group="categoryName">
> <cfif not categoryCount mod 4></tr><tr></cfif>
> <td valign="top">
> <b>#queryName.categoryName#</b><br>
> <cfset subCategoryCount=1>
> <cfoutput>
> <cfif subCategoryCount lte 3>
> #queryName.subCategoryName#<br>
> <cfelseif subCategoryCount eq 4>
> More...
> </cfif>
> <cfset
> subCategoryCount=subCategoryCount+1>
> </cfoutput>
>
> </td>
> <cfset categoryCount=categoryCount+1>
> </cfoutput>
> </tr>
> </table>
>
> There may be a more efficient way of doing what you proposed, but this
> gets the job done.
>
> Best,
>
> Nathan
>
>
> > -----Original Message-----
> > From: Guy McDowell [mailto:[EMAIL PROTECTED]
> > Sent: Friday, February 21, 2003 11:26 AM
> > To: CF-Talk
> > Subject: Re: 3 Cells Wide
> >
> >
> > Hi Dave (and everyone else),
> >
> > I've got the grouping and ordering down, it's the formatting
> > of the output that's the challenge. The trick is to get my
> > HTML table only 3 cols wide and then only have the first 3
> > results of the query on the Subcategory table displayed under
> > the appropriate Category heading.
> >
> > I have a straight HTML version on the index of my site to
> > illustrate where I am trying to go with this. It's at
> > http://www.guymcdowell.com
> >
> > TIA,
> >
> >
> >
> > Truly,
> >
> > Guy J. McDowell, M.M.C.P.
> > (705) 324-9144 ex 3422
> > [EMAIL PROTECTED]
> > ~~~~~~~~~~~~~~~~~~~~
> > Sir Sandford Fleming College
> > Frost Campus
> > P.O. Box 8000
> > Lindsay, Ontario
> > K9V 5E6
> >
> >
> > >>> [EMAIL PROTECTED] 02/21/03 10:33am >>>
> > >This is a borderline newbie question. Perhaps we should have a
> > >CF-Brainfart list. Anyway....
> > >
> > >Challenge: To have out put from two tables put into a three column
> > >wide, n-rows deep HTML table a la Yahoo! Each column's formatted
> > output
> > >would look something like this:
> > >
> > >Category Name
> > >
> > >Subcategory Name 1, Subcategory Name 2, Subcategory Name 3, more...
> > >
> > >Given: CF 5, MS Access 2000, tblCategory, tblSubcategory, one rusty
> > CF
> > >developer.
> > >
> > >I'm pretty sure this is a job for query-a-query and loop list while
> > >n<=3 type logic, but I just can't get it to jive. Help?
> >
> > Nah. Look into the "group" attribute of the <cfoutput
> > query...> tag. Just
> > group your query results by the category name and you should
> > be good to go.
> > The key is the ORDER BY clause in your SQL statement. You
> > want to make sure
> > you order by the category name so that CF can properly group the data.
> >
> > Here's a brief sample:
> >
> > <cfquery name="queryName" datasource="myDSN">
> > SELECT c.categoryName,
> > s.subcategory
> > FROM tblCategory c, tblSubcategory s
> > WHERE c.categoryid = s.categoryid
> > ORDER BY c.categoryName
> > </cfquery>
> >
> > Then in your output, you'd do something like:
> >
> > <cfoutput query="queryName" group="categoryid">
> > #queryName.categoryName#<br/>
> > <cfoutput>#queryName.subcategory#</cfoutput>
> > </cfoutput>
> >
> > The nested <cfoutput> is necessary because you need to "tell" CF which
> >
> > fields to group.
> >
> > Something like that should take care of your issue. Haven't
> > tested that
> >
> > code, but it looks Kosher.
> >
> > Regards,
> > Dave.
> >
> >
> >
> >
>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription:
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Your ad could be here. Monies from ads go to support these lists and provide more
resources for the community. http://www.fusionauthority.com/ads.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4