Sorry, I posted that without testing. To get a new row every three
cells, the output code should be:
<cfset categoryCount=1>
<table>
<tr>
<cfoutput query="queryName" group="categoryName">
<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>
<cfif categoryCount mod 3 eq 0></tr><tr></cfif>
<cfset categoryCount=categoryCount +1>
</cfoutput>
</tr>
</table>
--Nathan
> -----Original Message-----
> From: Nathan Mische
> Sent: Friday, February 21, 2003 12:23 PM
> To: CF-Talk
> 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
Structure your ColdFusion code with Fusebox. Get the official book at
http://www.fusionauthority.com/bkinfo.cfm
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4