• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 218
  • Last Modified:

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
0
teera
Asked:
teera
2 Solutions
 
gamebitsCommented:
Hi teera,

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

Gamebits

0
 
dr_dedoCommented:
<?
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now