<?php
$db = new mysqli('localhost', 'root', '', 'siakad');
$res = $db->query("SELECT * FROM tahun_akademik WHERE status = 'Aktif'");
$ta = $res->fetch_assoc();
print_r($ta);

$id_semester = $ta['id_semester_pddikti'] ?? $ta['kode_ta'];
echo "TA id_semester: $id_semester\n";

$res2 = $db->query("SELECT COUNT(*) as count, id_semester FROM kelas_perkuliahan GROUP BY id_semester");
while($r = $res2->fetch_assoc()) {
    print_r($r);
}
