Display title once followed by related fields


#1

I am working on a sign-up sheet for a number of available classes. I want the client to access this information in their browser with the following display:

Title of class1
enrollee1
enrollee2
enrollee3
enrollee4
enrollee5

Title of class2
enrollee1
enrollee2
enrollee3
enrollee4
enrollee5

I currently get:
Title of class1 enrollee1
Title of class1 enrollee2
Title of class1 enrollee3
Title of class1 enrollee4
Title of class1 enrollee5

Title of class2 enrollee1
Title of class2 enrollee2
Title of class2 enrollee3
Title of class2 enrollee4
Title of class2 enrollee5

Can someone please point me in the right direction? Essentailly I’m asking:

  1. print once only the title of all available classes
  2. print total records of signees for that specific class
  3. print the title of the class even if there are no current signees

I have a table with all of these fields (class, enrollee). Alternatively, I could join the information from two existing tables.

Just looking for the strategy that gets me pointed in the right direction.


#2

Move the display of the class name outside of the loop.