user3438945
user3438945

Reputation: 5

Do not display duplicate result

Here is my table register:

id  name         student_id  date     presence  absence_note    Tusername
50  hassimkhan    1112815    2014-03-08 P                        saahir
56  Karishma kods 1119112   2014-03-08  P                        saahir
58  Karishma kods 1119112   2014-03-09  P                        saahir           
60  hassimkhan    1112815   2014-03-09  A                        saahir

Here is my loop to display the result:

$retrieve = mysql_query("SELECT DISTINCT(student_id),presence FROM register"); 
    while($row = mysql_fetch_array($retrieve))          
        {
             echo $row['student_id'];
                }

I know for e.g id 56 and 58 with student_id: 1112815 record are different in a way, but i want to display it only one time e.g of result of these data:

1112815
1119112 

Any help?

Upvotes: 0

Views: 51

Answers (2)

rakeshjain
rakeshjain

Reputation: 1761

retrieve = mysql_query("SELECT student_id,presence FROM register GROUP BY student_id"); 
while($row = mysql_fetch_array($retrieve))          
{
  echo $row['student_id'];
}

Upvotes: 0

Rob W
Rob W

Reputation: 9142

Try GROUPing instead:

SELECT student_id, presence FROM register GROUP BY student_id

(untested)

Upvotes: 1

Related Questions