Forum Moderators: open
I'm having a issue that's probably easily answered, but I can't seem to resolve it. For simplicity, let's say I have one table, "Employees." In this table I have two columns: "Name" and "Title." In this company, the only titles are "Support 1," "Support 2," and "Support 3." There are approx. two employees in each support group.
What I would like to do is display the "Title" field with an HTML heading and list all the employees under that heading that match the title. I'd like the same for all the titles in the database, so I'd like it to look something like this:
<h1>Support 1</h1>
Employee 1
Employee 2
<h1>Support 2</h1>
Employee 3
Employee 4
Employee 5
<h1>Support 3</h1>
Employee 6
I can't seem to figure out how to do this. I can display the support levels on a separate page and list the applicable employees on the next page, but I'd like to list them all on one page. Short of writing separate queries with some crazy PHP include stuff, I'm at a loss. I'd be very thankful for any assistance.
$title = "";
Then loop over the results.
If the current title is equal to $title then do not print a title header.
If it is not then print <h1>(TITLE INFO)</h1> and set $title equal to the title info.
Print the name of the employee.
Repeat.