How To Show Total Data Based On Department


I have a code below :

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

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 :


include ("config.php");
$pesan = mysql_query("SELECT submission_no FROM t_submissions WHERE dept_name='$dept'");
$j = mysql_num_rows($pesan);
echo $j;
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.