Leakyradiator
Technical User
I have four tables in my database:
Org, Cat, Subcat and Links
Links is a linking table that contains the primary keys of Org, Cat, and Subcat for each record.
I'm trying to present each org. with all its categories, and present each subcategory for each category.
Here's the code I've been working with (unsuccessfully).
(I haven't even tried working with the subcategories yet).
<cfquery name="link1" datasource="#db#" username="#un#" password="#pw#">
select *
from links
</cfquery>
<cfloop query = "link1">
<cfquery name="org1" datasource="#db#" username="#un#" password="#pw#">
select *
from org
where org_id = #link1.org_id#
order by org_name1
</cfquery>
<cfset thiscatID = link1.cat_id>
<cfoutput>orgname: #org1.org_name1#<br></cfoutput>
<cfloop query="link1"><!---loop through link for org id to find catno--->
<cfquery name="getcat1" datasource="#db#" username="#un#" password="#pw#">
select cat_id, category
from categories
where cat_id = #thiscatID#
</cfquery>
<cfset categ=getcat1.category>
<cfloop query="getcat1">
<cfoutput>
Category #categ#<br>
</cfoutput>
</cfloop>
</cfloop>
</cfloop>
All help is appreciated greatly.
Thanks
Org, Cat, Subcat and Links
Links is a linking table that contains the primary keys of Org, Cat, and Subcat for each record.
I'm trying to present each org. with all its categories, and present each subcategory for each category.
Here's the code I've been working with (unsuccessfully).
(I haven't even tried working with the subcategories yet).
<cfquery name="link1" datasource="#db#" username="#un#" password="#pw#">
select *
from links
</cfquery>
<cfloop query = "link1">
<cfquery name="org1" datasource="#db#" username="#un#" password="#pw#">
select *
from org
where org_id = #link1.org_id#
order by org_name1
</cfquery>
<cfset thiscatID = link1.cat_id>
<cfoutput>orgname: #org1.org_name1#<br></cfoutput>
<cfloop query="link1"><!---loop through link for org id to find catno--->
<cfquery name="getcat1" datasource="#db#" username="#un#" password="#pw#">
select cat_id, category
from categories
where cat_id = #thiscatID#
</cfquery>
<cfset categ=getcat1.category>
<cfloop query="getcat1">
<cfoutput>
Category #categ#<br>
</cfoutput>
</cfloop>
</cfloop>
</cfloop>
All help is appreciated greatly.
Thanks