How To Show Total Data Based On Department

Advertisement

I have a code below :

<table>
<th class="th1">OT Date</th>
<td class="td1"><?php echo $date?></td>
<tr>
<th class="th" colspan="7">Department</th>
<tr>
<td class="td1" style="width: 100px;">Accounting</td>
[code].....

I plan to show total data based on Department. So in table example Admin, will automatically total the data.

and this is the php function code :

<?php

include ("config.php");
$dept="Admin";
$pesan = mysql_query("SELECT submission_no FROM t_submissions WHERE dept_name='$dept'");
$j = mysql_num_rows($pesan);
if($j>0)
{
echo $j;
}
else
{
echo "no data";
}?>

How can I set it if dept=Admin, then it will update total data to admin table, if dept=Accounting, it will update it too and so on.