开发者

displaying a group once in php mysql

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
   PAS开发者_Python百科S
TC4
   PASS

...and so on. I am unable to get the result I want LIKE ABOVE - any ideas where exactly I am making mistake?


change your sql to:

SELECT * FROM SELECT_PASS ORDER BY TESTCASE
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜