I am having trouble with a if-statement in a while loop i PHP. I have an array with teams named $all_teams. Let's say that it contains Team Blue, Team Red and Team Yellow. I also have a database where objects are assigned to teams.
DatabaseID | State | Team | ...
12 Ready Blue
33 Finished Red
65 Ready Blue
I am now trying to run the following code:
<?php
$query = "SELECT DISTINCT * FROM `dmt_objects` WHERE PipelineAndWorkflow = 'RWP WF Ready for 4Sprint' ORDER BY `Team` DESC ;";
$select_projects = mysql_query($query);
foreach($all_teams as $team){
echo '<tr id = '.$team.'><td>'.$team.'</td><td>';
while($all_objects = mysql_fetch_array($select_projects)){
if($all_objects['Team'] == $team){
echo ''.$all_objects['DatabaseID'].'</br>';
}
}
echo '</td></tr>';
}
?>
I am trying to creat a table that should look like this.
Blue | 12
65
Red | 33
Yellow |
The if-statment
if($all_objects['Team'] == $team)
is never true... Why? How can I fix my problem?