-1

When I'm trying to use the if statement below it wont work. Can I somehow compare the data I fetch in the mysql_fetch functions?

if (mysql_num_rows($select_projects) > 0) {

while($all_objects = mysql_fetch_array($select_projects)) {

    if($all_objects['Team'] !== ""){

            $current_team == $all_objects['Team'];
            echo '<tr id="'.$all_objects['Team'].'"> <td>'.$all_objects['Team'].'</td><td>';
                while($test = mysql_fetch_array($select_projects)){
                        if($test['PlannedSprint'] == "544" and  $all_objects['Team'] == $test['Team']){ // problem whit the last part of the ifstatement. it is never true. 
                        echo 'Testtest'.$all_objects['Team'].'</br>';
                        }
                }
            echo '</td></tr>';
        echo '';
        array_push($team, $all_objects['Team']);        
        //}
    }
}
}
e.klara.k
  • 369
  • 1
  • 6
  • 17

1 Answers1

2

You're popping two items off the return stack

while($all_objects = mysql_fetch_array($select_projects))

And

while($test = mysql_fetch_array($select_projects))

So you're pulling the first record off into $all_objects and then looping through the rest in $test.

You also need to stop using mysql_ functions as they are deprecated

Community
  • 1
  • 1
Machavity
  • 30,841
  • 27
  • 92
  • 100
  • Sorry, I don't understand what you mean... (I'm what you would call a beginner) – e.klara.k Sep 15 '15 at 14:19
  • What's a returnstack? And what du you mean by "pulling the first record of"? @Machavity – e.klara.k Sep 15 '15 at 14:43
  • @e.klara.k When you do a query you get back a result set. It's like an array in a sense. When you call that `fetch_array()` function it grabs a row off the stack – Machavity Sep 15 '15 at 14:48
  • @e.klara.k I'm not sure exactly what you're trying to do, but you should probably parse your rows into a PHP array and work with that instead – Machavity Sep 15 '15 at 14:50