这是我的表寄存器:
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
这是我的循环显示结果:
$retrieve = mysql_query("SELECT DISTINCT(student_id),presence FROM register");
while($row = mysql_fetch_array($retrieve))
{
echo $row['student_id'];
}
我知道例如 id 56和58与student_id:1112815记录在某种程度上是不同的,但我想只显示一次,例如这些数据的结果:
1112815
1119112
任何帮助?
答案 0 :(得分:1)
请尝试GROUP
:
SELECT student_id, presence FROM register GROUP BY student_id
(未测试的)
答案 1 :(得分:0)
retrieve = mysql_query("SELECT student_id,presence FROM register GROUP BY student_id");
while($row = mysql_fetch_array($retrieve))
{
echo $row['student_id'];
}