如果我有 2 人或更多人,我需要打印多个未读笔记的计数器总和


i need to print the sum of counters of unread note for more than one if i have 2 or more person

此代码向我显示每个不阅读笔记的学生,所以我需要这些未读笔记的计数器来打印它如何获得所有未读笔记的总和?

 $query=mysql_query("SELECT * FROM students WHERE parents_id='".$pid."'");
while($r=mysql_fetch_assoc($query)){
echo'<tr>';
echo'<td><b>'.$r['first_name'].'  '. $r['last_name'].'</b></td>';
echo'<td>'.$r['class_name'].'</td>';
$quer=mysql_query("SELECT count(id) FROM notes  WHERE student_id='".$r['id']."' AND isread='0' ");
$count=mysql_fetch_array($quer);
$c=$count[0];
echo'<td><b><span style="color:red;text-align:center;">('.$c.') '.'UnRread</b></td>';
echo'<td><b>'."<a href=viewnote.php?viewnote&sid=".$r['id']."&name=".$r['first_name']."&last=".$r['last_name']."' >View</a>".'</b></td>';
echo'</tr>';

保持计数的运行总数:

$totalCount = 0;
$query=mysql_query("SELECT * FROM students WHERE parents_id='".$pid."'");
while($r=mysql_fetch_assoc($query)){
echo'<tr>';
echo'<td><b>'.$r['first_name'].'  '. $r['last_name'].'</b></td>';
echo'<td>'.$r['class_name'].'</td>';
$quer=mysql_query("SELECT count(id) FROM notes  WHERE student_id='".$r['id']."' AND isread='0' ");
$count=mysql_fetch_array($quer);
$c=$count[0];
$totalCount = $totalCount + $c;
echo'<td><b><span style="color:red;text-align:center;">('.$c.') '.'UnRread</b></td>';
echo'<td><b>'."<a href=viewnote.php?viewnote&sid=".$r['id']."&name=".$r['first_name']."&last=".$r['last_name']."' >View</a>".'</b></td>';
echo'</tr>';

在 while 循环之后:

echo $totalCount;