displaying a group once in php mysql

Posted by JPro on Stack Overflow See other posts from Stack Overflow or by JPro
Published on 2010-03-20T19:37:11Z Indexed on 2010/03/20 19:41 UTC
Read the original article Hit count: 367

Filed under:
|
|

I have some data like this :

1   TC1 PASS
2   TC2 FAIL
3   TC3 INCONC
4   TC1 FAIL
5   TC21    FAIL
6   TC4 PASS
7   TC3 PASS
8   TC2 FAIL
9   TC1 TIMEOUT
10  TC21    FAIL

If I try the below code :

<?php

 mysql_connect("localhost", "root", "pop") or die(mysql_error());
      mysql_select_db("jpd") or die(mysql_error());
      $oustanding_fails = mysql_query("select * from SELECT_PASS ") or die(mysql_error());  

      $resultSetArray = array();
      $platform;
       while($row1 = mysql_fetch_array( $oustanding_fails )) {



       if(trim($row1['TESTCASE']) <> trim($platform))   {
       echo $row1['TESTCASE']."-"; 
       $platform = $row1['TESTCASE'];
       }

        echo $row1['RESULT'] ."<br>";


}
?>

to get a result like this :

TC1
   PASS
   FAIL
   TIMEOUT
TC2
   FAIL
   FAIL
TC3
   INCONC
   PASS
TC4
   PASS

AND SO ON.

I am unable to get the result I want. Any ideas where exactly I am making mistake?

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql