I'm working on getting a value from a database table, then getting another value based on the first value. This first part is working fine. I'm just getting a list of organization names and outputting them to a list:
$org_name = mysql_query('SELECT org_name FROM Orgs_Teams GROUP BY org_name');
echo "<ul>";
while ($org_row = mysql_fetch_row($org_name)) {
echo "<li>{$org_row[0]}</li>";
}
echo "</ul>";
But here's where I'm stuck. I now need to get the names of each team within each organization. I'm working with a simple database table with two columns: org_name & team_name.
Ultimately I'm looking to have a nested list for my nav menu like this (which gets repeated for each Org Name):
- Org Name 1
- Team Name 1
- Team Name 2
- Team Name 3
I've been messing with different queries like this:
$team_name_query = mysql_query('SELECT team_name FROM Orgs_Teams WHERE org_name = "$org_name" ');
But haven't been able to get anything to work. My thought was that the team name query would go inside the 'while' loop and create the nested list but I'm stuck. Thanks in advance for any help.