Jump to content

Group organizational chart


xionhack

Recommended Posts

Hello, I have a project that I've been working for a while but havent been able to do it. I have to make a table that goes first in the header the group leader, then in the second row it's going to appear the different team leaders that are bellow that group leader, and then bellow every team leader, the members that are bellow him.

 

I have tried different ways to make the sql tables but I dont know if im doing it right, I'll paste an html code to show kinda what I am looking for. I will really appreciate if someone can help.

 

<table border="1">
  <tr>
    <th colspan="4" scope="col">Group Leader 1</th>
  </tr>
  <tr>
    <td>Team Leader 1</td>
    <td>Team Leader 2</td>
    <td>Team Leader 3</td>
    <td>Team Leader 4</td>
  </tr>
  <tr>
    <td>Member 1</td>
    <td>Member 5</td>
    <td>Member 8</td>
    <td>Member 12</td>
  </tr>
  <tr>
    <td>Member 2</td>
    <td>Member 6</td>
    <td>Member 9</td>
    <td>Member 13</td>
  </tr>
  <tr>
    <td>Member 3</td>
    <td>Member 7</td>
    <td>Member 10</td>
    <td> </td>
  </tr>
  <tr>
    <td>Member 4</td>
    <td> </td>
    <td>Member 11</td>
    <td> </td>
  </tr>
</table>

<table border="1">
  <tr>
    <th colspan="3" scope="col">Group Leader 2</th>
  </tr>
  <tr>
    <td>Team Leader 5</td>
    <td>Team Leader 6</td>
    <td>Team Leader 7</td>
  </tr>
  <tr>
    <td>Member 14</td>
    <td>Member 18</td>
    <td>Member 21</td>
  </tr>
  <tr>
    <td>Member 15</td>
    <td>Member 19</td>
    <td>Member 22</td>
  </tr>
  <tr>
    <td>Member 16</td>
    <td>Member 20</td>
    <td>Member 23</td>
  </tr>
  <tr>
    <td>Member 17</td>
    <td> </td>
    <td>Member 24</td>
  </tr>
</table>


Link to comment
https://forums.phpfreaks.com/topic/149582-group-organizational-chart/
Share on other sites

This HTML works fine, so I assume you have no problem with that.

 

So the question is: what do you have problem with? You posted in PHP section, wrote about SQL tables and pasted HTML code... That's very confusing, so please try to explain clearly what do you want to achieve.

The database and the way to call it from the php! I've tried many different ways and at the end is not good. I designed 3 tables

 

group table, with group_id (pk) and group_leader (here goes the id of the member that is a group leader)

 

team table, with team_id (pk) , team_leader (here goes the id of the member that is a team leader),

group_id (here goes the id of the group that team belongs to)

 

member table, here is all the info of the members and one column called team_id that is the id of the team that member belongs to.

 

I am very new at php, I'm going to post the code I have so far, please criticize it as much as you can! I want to become a good programmer! thanks!

 

<div>
<?php //Get groups and put them in a different table
	$group_set = get_groups(); // function calls all the groups
	while($groups = mysql_fetch_array($group_set)){
		$output .= "<table border=\"1\">\n";
		$output .=	"<th>\n";
			$output .=	"<td>";
				$group_leader = get_personal_data($groups['member_id']); //function gets the personal info of the member through the id		
			$output .=	$group_leader['first_name'] . " " . $group_leader['last_name'] ; //Display the first name and last name
			$output .=  "</td>\n";
		$output .=	"</th>\n";

				$team_leader_set = get_t_leader($groups['member_id']); //function calls all the teams
			 $output.= "<tr>\n";
					while($team_leader = mysql_fetch_array($team_leader_set)){
					$output .= "<td>";
							$team_leader = get_personal_data($team_leader['member_id']); //function gets the personal info of the member through 
					$output .= $team_leader['first_name'] . " " . $team_leader['last_name'] . "</td>";
		$output .=  	"</tr>\n";
				}


		$output .=  "</table>\n";

	}
	echo $output;
	?>

</div>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.