  <div class="card">
    <div class="card-body">
<h2>ข้อมูลแผนกวิชา </h2>
<!-- <div align="right"><a href="?op=summarize&module=groups-list&show=all" class="btn btn-secondary" role="button"> <i class="fa fa-share" aria-hidden="true"></i> แสดงกลุ่มเรียนทั้งหมด</a> </div> -->
 <?php
global $connect;	
$sql="Select * From department order by department_id  ASC";
$db_query=mysqli_query($connect,$sql);
$num_rows=mysqli_num_rows($db_query); /* นับ Reccord ที่พบ */
echo "มีจำนวน <b>$num_rows</b> รายการ ";

?>
  <table class="table table-hover table-striped table-condensed table-sm table-bordered ">
    <thead>
      <tr>
        <th width="8%"><center>#</center></th>
        <th width="26%">แผนกวิชา</th>
		  <th style="text-align: right" width="25%">ครูที่ปรึกษา</th>
		  <th style="text-align: right" width="21%">กลุ่มเรียน</th>
  		 <th style="text-align: right" width="20%">นักศึกษา</th> 
      </tr>
    </thead>
    <tbody>
	<?php
$a=0;
$no=1;
$sum_group=0;				
$sum_student=0;		
while($a < $num_rows)
{
	$result = mysqli_fetch_array($db_query);
	$department_id=$result['department_id'];
	$department_name=$result['department_name'];

    $num_teacher=num_record("department_teacher","where department_id='$department_id'  ");
	?>	
    	
		
      <tr>
        <td align="center"><?php echo $no;?>.<a name="<?=$department_id?>" id="<?=$department_id?>"></a></td>
        <td><?=$department_name?></td>
		 <td style="text-align: right"><a href="?op=techer&module=list&show=depart&depart=<?=$department_id?>"><?=$num_teacher?></a></td>
		 <td style="text-align: right">&nbsp;</td> 	   

		<td style="text-align: right"><?php //ตรวจสอบว่ามีรายการนี้หรือยัง
		$result_regis_summarize_student=select("regis_summarize_student","where academicYear='$academicYear' AND semester='$semester' AND summarize_name='$level_name' ");  
		$totalStudent=$result_regis_summarize_student["totalStudent"]; 
		$sum_student=$sum_student+$totalStudent;
		echo "<b>"; 
		echo number_format($totalStudent); 
		echo"</b> คน"; 
		?> 
		  </td>  
      </tr>



   <?php
        $no++;
		$a++;
}
	
	?>
<tr>
	<td colspan="2"><center><b>รวม</b></center></td>
	 <td align="center" style="text-align: right"><b><?php echo number_format($sum_group); ?></b> คน</td>
	 <td align="center" style="text-align: right">&nbsp;</td> 	
	<td style="text-align: right"><b><?php echo number_format($sum_student); ?></b> คน</td>
</tr>

    </tbody>
  </table>

</div>
</div></div>