php to cut the duplicate data

id   box   stare
1    3       1
2    3       2
3    3       2
4    3       3
5    3       5
6    3        5
7    4        1
8    4        1
9    4        5
10  4        7
11  4        11


the  
The out put should be  stare is 3-1 3-2 3-3 3-5  4-1  4-5 4-7  ( the duplicate stare is use only one)
Plese show me how to write the program the table above is come form my sql database
teeraAsked:
Who is Participating?
 
gamebitsConnect With a Mentor Commented:
Hi teera,

$Result = mysql_query("SELECT DISTINCT * FROM tablename WHERE stare = '$stare'");

Gamebits

0
 
dr_dedoConnect With a Mentor Commented:
<?
mysql_connect ('localhost','root','');
$con = mysql_select_db('database name');

$result = mysql_query ("select box, stare from table1 group by stare");
if (mysql_num_rows($result)){
    while ($row=mysql_fetch_assoc($result)){
       echo "Box= {$row['box']}, stare= {$row['stare']}<br>";
   }
}
?>
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.