diff --git a/P3/controller/statistik_controller.php b/P3/controller/statistik_controller.php index e7b85b4ef98ab160bb60b21ad110b29d7eb74931..cce7e0411cba387a82b5cbb43388abeac73beba4 100644 --- a/P3/controller/statistik_controller.php +++ b/P3/controller/statistik_controller.php @@ -9,20 +9,21 @@ function getStatistik(){ $i = 0; // hitung per skpd foreach ($skpd as $skpd){ - $res[$i]['nama'] = $skpd['nama']; - $res[$i]['sum'] = 0; - $res[$i]['count'] = 0; - $res[$i]['avg'] = 0; + $sum = 0; + $count = 0; + $avg = 0; foreach($penilaian as $n){ - if (strcmp($skpd['nama'], $n['unit_kerja'])) { - $res[$i]['sum'] += $n['nilai']; - $res[$i]['count']++; + if (strcmp($skpd['nama'], $n['unit_kerja']) == 0) { + $res[$i]['nama'] = $skpd['nama']; + $sum += $n['nilai']; + $count++; } } - if ($res[$i]['count'] != 0) { - $res[$i]['avg'] = $res[$i]['sum']/$res[$i]['count']; + if ($count != 0) { + $avg = $sum/$count; + $res[$i]['avg'] = $avg; $i++; - } + } } return $res; diff --git a/P3/index.php b/P3/index.php index 414b19dbfb12aa16bdbbb93afd57194c72b40a0a..bcfa2178dda3971a80747b4deb4ce136e956d5f3 100644 --- a/P3/index.php +++ b/P3/index.php @@ -93,10 +93,11 @@ </div> <div class="panel-body no-padder"> <div class="wrapper20 inline full-width"> + Keterangan: <?php $skpd = getStatistik(); foreach ($skpd as $skpd){ - echo $skpd['nama'] . "<br/>"; + echo "<li>". $skpd['nama'] . "</li>"; } ?> </div>