>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
                                

Reply via email to