<?php
$db = new mysqli('localhost', 'root', '', 'siakad');
$res = $db->query("SELECT kp.id_program_studi, mk.semester, COUNT(*) FROM kelas_perkuliahan kp LEFT JOIN mata_kuliah mk ON mk.nama_mata_kuliah = kp.nama_mata_kuliah AND mk.id_program_studi = kp.id_program_studi WHERE kp.id_semester='20252' GROUP BY kp.id_program_studi, mk.semester");
while($r = $res->fetch_assoc()) {
    print_r($r);
}
