使用mysql_fetch_array多次PHP

时间:2015-09-15 14:11:40

标签: php mysql fetch

当我尝试使用下面的if语句时,它无法正常工作。我可以以某种方式比较我在mysql_fetch函数中获取的数据吗?

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']);        
        //}
    }
}
}

1 个答案:

答案 0 :(得分:2)

你从退货堆中弹出两件物品

while($all_objects = mysql_fetch_array($select_projects))

while($test = mysql_fetch_array($select_projects))

因此,您将第一条记录移至$all_objects,然后在$test中循环显示其余记录。

您还需要stop using mysql_ functions,因为它们已被弃用