Need help with outputing query group names
I am trying to come up with a way to output group headers, then all the records under each group header etc. It would be easy, except there is a twist with what i want to do.
Normally if I have this set of data (which I ‘borrowed’ from a site that showed the closest to what I’m looking for):
Example Table Setup:
TABLE [Numbers]
(Name, NUMBER)
Dave Bosky 843-444-4444
Dave Bosky 843-555-5555
Matthew Small 843-111-1111
Matthew Small _843-222-2222
Matthew Small 843-333-3333
I could use the following code:
<cfoutput query="somequery" group="name">
#name#<br>
<cfoutput>
#phonenumber#<br>
</cfoutput>
<hr>
</cfoutput>
And get this:
Dave Bosky
843-444-4444
843-555-5555
-------------------
Matthew Small
843-111-1111
843-222-2222
843-333-3333
-------------------
BUT, my actual tables are not set up like this. Rather than recording each name with each record, I would have an ID that is the foreign key for another table.
Current table set up would look like this:
TABLE [People]
(ID, NAME)
1 Dave Bosky
2 Matthew Small
TABLE [Phones]
(PEOPLE_ID, NUMBER)
1 843-444-4444
1 843-555-5555
2 843-111-1111
2 843-222-2222
2 843-333-3333
So this output would actually give me this with my current setup and the query code above:
1
843-444-4444
843-555-5555
-------------------
2
843-111-1111
843-222-2222
843-333-3333
-------------------
How do I keep my current setup but create a query that achieves the same result from the top? (Output the names from the People table as the group headers, but the data from the Phones table underneath that)
