php to cut the duplicate data

Posted on 2006-05-12
Last Modified: 2006-11-18
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 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
Question by:teera
    LVL 28

    Accepted Solution

    Hi teera,

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


    LVL 16

    Assisted Solution

    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>";

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    The Client Need Led Us to RSS I recently had an investment company ask me how they might notify their constituents about their newsworthy publications.  Probably you would think "Facebook" or "Twitter" but this is an interesting client.  Their cons…
    This article will explain how to display the first page of your Microsoft Word documents (e.g. .doc, .docx, etc...) as images in a web page programatically. I have scoured the web on a way to do this unsuccessfully. The goal is to produce something …
    The viewer will learn how to dynamically set the form action using jQuery.
    The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

    746 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now