Bagaimana mencetak nilai dari looping menggunakan libarary mPDF?

Library mPDF ini adalah untuk menampilkan dan mencetak nilai dalam bentuk pdf.

untuk menampilkan tabel sudah berhasil dalam bentuk pdf,

image.png

tetapi pada gambar diatas tepatnya di tabel ke 2 tidak menampilkan nilai yang ditampilkan dengan looping while sql. hanya menampilkan header tabel nya saja.

image.png

harusnya tampilan yang benar adalah seperti gambar dibawah ini,

image.png

untuk saat ini yang jadi permasalahan yang terduga adalah operasi looping nya, mohon bantuannya gan?

berikut adalah bentuk kode saya

<?php
//panggil file conn.php untuk menghubung ke server
include('../system/config/conn.php');
ob_start();
ini_set("memory_limit","-1");
set_time_limit(300);

$nama_dokumen='Report';
define('_MPDF_PATH','../report/MPDF57/');
include(_MPDF_PATH . 'mpdf.php');
$mpdf=new mPDF('utf-8', 'FOLIO','0','0',10,'7');

//merubah waktu kedalam format indonesia
$hari = array ("Minggu","Senin","Selasa","Rabu","Kamis","Jumat","Sabtu");
$bln = array ("","Januari","Februari","Maret","April","Mei","Juni","Juli","Agustus","September","Oktober","November","Desember");

//mendapatkan informasi
$id_kecamatan = $_GET['id_kecamatan'];
$id_sekolah = $_GET['id_sekolah'];

echo "<h4 align=\"center\"><u>LAPORAN BULANAN SEKOLAH MENENGAH PERTAMA (SMP)</u></h4>";

$query = mysql_query("SELECT a.*, b.nm_kecamatan
AS nm_kecamatan, c.nm_sekolah AS nm_sekolah
FROM sekolah a
JOIN kecamatan b ON a.id_kecamatan = b.id_kecamatan
JOIN sekolah c ON a.id_sekolah = c.id_sekolah
WHERE a.id_kecamatan = '$id_kecamatan' and a.id_sekolah = '$id_sekolah'") or die(mysql_error());
$data = mysql_fetch_array($query);

$nm_sekolah = $data['nm_sekolah'];
$akreditasi = $data['akreditasi'];
$alamat_sekolah = $data['alamat_sekolah'];
$untuk_bulan = $bln[date('m')];
$tahun_pelajaran1 = date('Y');
$tahun_pelajaran2 = date('Y')+1;
$npsn = $data['npsn'];

///ini adalah tabel pertama////
echo "<table style=\"border-collapse:collapse;\" align=\"center\" cellpadding=\"1\" cellspacing=\"0\">

<thead>
<tr>
<th align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\">&nbsp;NAMA SEKOLAH&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\">&nbsp;$nm_sekolah&nbsp;</td>
<th align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\">&nbsp;ALAMAT SEKOLAH&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\">&nbsp;$alamat_sekolah&nbsp;</td>
</tr>

<tr>
<th align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;AKREDITASI&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;$akreditasi&nbsp;</td>
<th align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;NSS&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\"></td>
</tr>

<tr>
<th align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;UNTUK BULAN&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;$untuk_bulan&nbsp;</td>
<th align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;NIS&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\"></td>
</tr>

<tr>
<th align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;TAHUN PELAJARAN&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;$tahun_pelajaran1/$tahun_pelajaran2&nbsp;</td>
<th align=\"left\" valign=\"top\" style=\"font-size:12px;border:solid 1px black;\">&nbsp;NPSN&nbsp;</th>
<td align=\"left\" valign=\"top\" style=\"font-size:12spx;border:solid 1px black;\">&nbsp;$npsn&nbsp;</td>
</tr>
</thead>

<tbody>
</tbody>
</table>";

////end tabel pertama////////

echo "&nbsp;";

////ini adalah tabel kedua/////

echo " <table style=\"border-collapse:collapse;\" align=\"center\" cellpadding=\"1\" cellspacing=\"0\" width=\"100%\" border=\"1\">
<thead>
<tr>

<th rowspan=\"2\" colspan=\"2\"><center>&nbsp;KELAS ROMBEL&nbsp;</center></th>
<th colspan=\"3\"><center>&nbsp;BULAN LALU&nbsp;</center></th>
<th colspan=\"2\"><center>&nbsp;KELUAR&nbsp;</center></th>
<th colspan=\"2\"><center>&nbsp;MASUK&nbsp;</center></th>
<th colspan=\"3\"><center>&nbsp;BULAN INI&nbsp;</center></th>
<th colspan=\"7\"><center>&nbsp;SISWA MENURUT AGAMA&nbsp;</center></th>
<th colspan=\"8\"><center>&nbsp;SISWA MENURUT UMUR (TAHUN)&nbsp;</center></th>

</tr>

<tr>
<th><center>&nbsp;L&nbsp;</center></th>
<th><center>&nbsp;P&nbsp;</center></th>
<th><center>&nbsp;JLH&nbsp;</center></th>

<th><center>L</center></th>
<th><center>P</center></th>

<th><center>L</center></th>
<th><center>P</center></th>

<th><center>L</center></th>
<th><center>P</center></th>
<th><center>&nbsp;JLH&nbsp;</center></th>

<th><center>&nbsp;ISLAM&nbsp;</center></th>
<th><center>&nbsp;KRISTEN PROTESTAN&nbsp;</center></th>
<th><center>&nbsp;KRISTEN KATOLIK&nbsp;</center></th>
<th><center>&nbsp;BUDDHA&nbsp;</center></th>
<th><center>&nbsp;HINDU&nbsp;</center></th>
<th><center>&nbsp;KONGHUCU&nbsp;</center></th>
<th><center>&nbsp;JLH&nbsp;</center></th>
<th><center>&nbsp;=/<11&nbsp;</center></th>
<th><center>&nbsp;12&nbsp;</center></th>
<th><center>&nbsp;13&nbsp;</center></th>
<th><center>&nbsp;14&nbsp;</center></th>
<th><center>&nbsp;15&nbsp;</center></th>
<th><center>&nbsp;16&nbsp;</center></th>
<th><center>&nbsp;=/>17&nbsp;</center></th>
<th><center>&nbsp;JLH&nbsp;</center></th>
</tr>

<tr>
<th><center><i>1</i></center></th>
<th><center><i>2</i></center></th>
<th><center><i>3</i></center></th>
<th><center><i>4</i></center></th>
<th><center><i>5</i></center></th>

<th><center><i>6</i></center></th>
<th><center><i>7</i></center></th>
<th><center><i>8</i></center></th>
<th><center><i>9</i></center></th>
<th><center><i>&nbsp;10&nbsp;</i></center></th>

<th><center><i>&nbsp;11&nbsp;</i></center></th>
<th><center><i>12</i></center></th>
<th><center><i>13</i></center></th>
<th><center><i>14</i></center></th>
<th><center><i>15</i></center></th>

<th><center><i>16</i></center></th>
<th><center><i>17</i></center></th>
<th><center><i>18</i></center></th>
<th><center><i>19</i></center></th>
<th><center><i>20</i></center></th>

<th><center><i>21</i></center></th>
<th><center><i>22</i></center></th>
<th><center><i>23</i></center></th>
<th><center><i>24</i></center></th>
<th><center><i>25</i></center></th>

<th><center><i>26</i></center></th>
<th><center><i>27</i></center></th>

</tr>
</thead>

<tbody>";

$sql = mysql_query("SELECT a.*, b.nm_kecamatan AS nm_kecamatan, c.nm_sekolah AS nm_sekolah
FROM keadaan_siswa a
JOIN kecamatan b ON a.id_kecamatan = b.id_kecamatan
JOIN sekolah c ON a.id_sekolah = c.id_sekolah
WHERE a.id_sekolah = '$_SESSION[id_sekolah]' AND MONTH(tanggal_data) = MONTH(CURRENT_DATE)
ORDER BY id_kecamatan ASC");
$row = array();
while ($data = mysql_fetch_array($sql)) $row[] = $data;
foreach ($row as $a){
$bulan_lalu_laki_vii = $a[0];
$bulan_lalu_perempuan_vii = $a[1];
$keluar_laki_vii = $a[2];
$keluar_perempuan_vii = $a[3];
$masuk_laki_vii = $a[4];
$masuk_perempuan_vii = $a[5];
$bulan_ini_laki_vii = $a[6];
$bulan_ini_perempuan_vii = $a[7];

$bulan_lalu_laki_viii = $a[8];
$bulan_lalu_perempuan_viii = $a[9];
$keluar_laki_viii = $a[10];
$keluar_perempuan_viii = $a[11];
$masuk_laki_viii = $a[12];
$masuk_perempuan_viii = $a[13];
$bulan_ini_laki_viii = $a[14];
$bulan_ini_perempuan_viii = $a[15];

$bulan_lalu_laki_ix = $a[16];
$bulan_lalu_perempuan_ix = $a[17];
$keluar_laki_ix = $a[18];
$keluar_perempuan_ix = $a[19];
$masuk_laki_ix = $a[20];
$masuk_perempuan_ix = $a[21];
$bulan_ini_laki_ix = $a[22];
$bulan_ini_perempuan_ix = $a[23];

$mpdf->WriteHTML("aa: $bulan_lalu_laki_vii");
echo "<tr>
<tr>

<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>VII</center></td>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>0</center></td>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($bulan_lalu_laki_vii);</center></td>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($bulan_lalu_perempuan_vii);</center></td>
<th align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($bulan_lalu_laki_vii)+$mpdf->WriteHTML($bulan_lalu_perempuan_vii);?></center></th>

<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($keluar_laki_vii);</center></td>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($keluar_perempuan_vii);</center></td>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($masuk_laki_vii);</center></td>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($masuk_perempuan_vii);</center></td>

<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($bulan_ini_laki_vii);</center></td>
<td align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($bulan_ini_perempuan_vii);</center></td>
<th align=\"left\" valign=\"top\" style=\"font-size:12px; border:solid 1px black;\"><center>$mpdf->WriteHTML($bulan_ini_laki_vii)+$mpdf->WriteHTML($bulan_ini_perempuan_vii);</center></th>";

$sql1 = mysql_query("SELECT a.*, b.nm_kecamatan AS nm_kecamatan, c.nm_sekolah AS nm_sekolah,
IFNULL(sum(a.agama_siswa='Islam' AND (rombel_siswa = 'VII-A' OR rombel_siswa = 'VII-B' OR rombel_siswa = 'VII-C' OR rombel_siswa = 'VII-D' OR rombel_siswa = 'VII-E' OR rombel_siswa = 'VII-F' OR rombel_siswa = 'VII-G' OR rombel_siswa = 'VII-H' OR rombel_siswa = 'VII-I' OR rombel_siswa = 'VII-J' OR rombel_siswa = 'VII-K' OR rombel_siswa = 'VII-L' OR rombel_siswa = 'VII-M' OR rombel_siswa = 'VII-N' OR rombel_siswa = 'VII-O')),0) AS agama_siswa_islam_vii, IFNULL(sum(a.agama_siswa='Protestan' AND (rombel_siswa = 'VII-A' OR rombel_siswa = 'VII-B' OR rombel_siswa = 'VII-C' OR rombel_siswa = 'VII-D' OR rombel_siswa = 'VII-E' OR rombel_siswa = 'VII-F' OR rombel_siswa = 'VII-G' OR rombel_siswa = 'VII-H' OR rombel_siswa = 'VII-I' OR rombel_siswa = 'VII-J' OR rombel_siswa = 'VII-K' OR rombel_siswa = 'VII-L' OR rombel_siswa = 'VII-M' OR rombel_siswa = 'VII-N' OR rombel_siswa = 'VII-O')),0) AS agama_siswa_protestan_vii, IFNULL(sum(a.agama_siswa='Katolik' AND (rombel_siswa = 'VII-A' OR rombel_siswa = 'VII-B' OR rombel_siswa = 'VII-C' OR rombel_siswa = 'VII-D' OR rombel_siswa = 'VII-E' OR rombel_siswa = 'VII-F' OR rombel_siswa = 'VII-G' OR rombel_siswa = 'VII-H' OR rombel_siswa = 'VII-I' OR rombel_siswa = 'VII-J' OR rombel_siswa = 'VII-K' OR rombel_siswa = 'VII-L' OR rombel_siswa = 'VII-M' OR rombel_siswa = 'VII-N' OR rombel_siswa = 'VII-O')),0) AS agama_siswa_katolik_vii, IFNULL(sum(a.agama_siswa='Buddha' AND (rombel_siswa = 'VII-A' OR rombel_siswa = 'VII-B' OR rombel_siswa = 'VII-C' OR rombel_siswa = 'VII-D' OR rombel_siswa = 'VII-E' OR rombel_siswa = 'VII-F' OR rombel_siswa = 'VII-G' OR rombel_siswa = 'VII-H' OR rombel_siswa = 'VII-I' OR rombel_siswa = 'VII-J' OR rombel_siswa = 'VII-K' OR rombel_siswa = 'VII-L' OR rombel_siswa = 'VII-M' OR rombel_siswa = 'VII-N' OR rombel_siswa = 'VII-O')),0) AS agama_siswa_buddha_vii, IFNULL(sum(a.agama_siswa='Hindu' AND (rombel_siswa = 'VII-A' OR rombel_siswa = 'VII-B' OR rombel_siswa = 'VII-C' OR rombel_siswa = 'VII-D' OR rombel_siswa = 'VII-E' OR rombel_siswa = 'VII-F' OR rombel_siswa = 'VII-G' OR rombel_siswa = 'VII-H' OR rombel_siswa = 'VII-I' OR rombel_siswa = 'VII-J' OR rombel_siswa = 'VII-K' OR rombel_siswa = 'VII-L' OR rombel_siswa = 'VII-M' OR rombel_siswa = 'VII-N' OR rombel_siswa = 'VII-O')),0) AS agama_siswa_hindu_vii, IFNULL(sum(a.agama_siswa='Konghucu' AND (rombel_siswa = 'VII-A' OR rombel_siswa = 'VII-B' OR rombel_siswa = 'VII-C' OR rombel_siswa = 'VII-D' OR rombel_siswa = 'VII-E' OR rombel_siswa = 'VII-F' OR rombel_siswa = 'VII-G' OR rombel_siswa = 'VII-H' OR rombel_siswa = 'VII-I' OR rombel_siswa = 'VII-J' OR rombel_siswa = 'VII-K' OR rombel_siswa = 'VII-L' OR rombel_siswa = 'VII-M' OR rombel_siswa = 'VII-N' OR rombel_siswa = 'VII-O')),0) AS agama_siswa_konghucu_vii,
IFNULL(sum(a.agama_siswa='Islam' AND (rombel_siswa = 'VIII-A' OR rombel_siswa = 'VIII-B' OR rombel_siswa = 'VIII-C' OR rombel_siswa = 'VIII-D' OR rombel_siswa = 'VIII-E' OR rombel_siswa = 'VIII-F' OR rombel_siswa = 'VIII-G' OR rombel_siswa = 'VIII-H' OR rombel_siswa = 'VIII-I' OR rombel_siswa = 'VIII-J' OR rombel_siswa = 'VIII-K' OR rombel_siswa = 'VIII-L' OR rombel_siswa = 'VIII-M' OR rombel_siswa = 'VIII-N' OR rombel_siswa = 'VIII-O')),0) AS agama_siswa_islam_viii, IFNULL(sum(a.agama_siswa='Protestan' AND (rombel_siswa = 'VIII-A' OR rombel_siswa = 'VIII-B' OR rombel_siswa = 'VIII-C' OR rombel_siswa = 'VIII-D' OR rombel_siswa = 'VIII-E' OR rombel_siswa = 'VIII-F' OR rombel_siswa = 'VIII-G' OR rombel_siswa = 'VIII-H' OR rombel_siswa = 'VIII-I' OR rombel_siswa = 'VIII-J' OR rombel_siswa = 'VIII-K' OR rombel_siswa = 'VIII-L' OR rombel_siswa = 'VIII-M' OR rombel_siswa = 'VIII-N' OR rombel_siswa = 'VIII-O')),0) AS agama_siswa_protestan_viii, IFNULL(sum(a.agama_siswa='Katolik' AND (rombel_siswa = 'VIII-A' OR rombel_siswa = 'VIII-B' OR rombel_siswa = 'VIII-C' OR rombel_siswa = 'VIII-D' OR rombel_siswa = 'VIII-E' OR rombel_siswa = 'VIII-F' OR rombel_siswa = 'VIII-G' OR rombel_siswa = 'VIII-H' OR rombel_siswa = 'VIII-I' OR rombel_siswa = 'VIII-J' OR rombel_siswa = 'VIII-K' OR rombel_siswa = 'VIII-L' OR rombel_siswa = 'VIII-M' OR rombel_siswa = 'VIII-N' OR rombel_siswa = 'VIII-O')),0) AS agama_siswa_katolik_viii, IFNULL(sum(a.agama_siswa='Buddha' AND (rombel_siswa = 'VIII-A' OR rombel_siswa = 'VIII-B' OR rombel_siswa = 'VIII-C' OR rombel_siswa = 'VIII-D' OR rombel_siswa = 'VIII-E' OR rombel_siswa = 'VIII-F' OR rombel_siswa = 'VIII-G' OR rombel_siswa = 'VIII-H' OR rombel_siswa = 'VIII-I' OR rombel_siswa = 'VIII-J' OR rombel_siswa = 'VIII-K' OR rombel_siswa = 'VIII-L' OR rombel_siswa = 'VIII-M' OR rombel_siswa = 'VIII-N' OR rombel_siswa = 'VIII-O')),0) AS agama_siswa_buddha_viii, IFNULL(sum(a.agama_siswa='Hindu' AND (rombel_siswa = 'VIII-A' OR rombel_siswa = 'VIII-B' OR rombel_siswa = 'VIII-C' OR rombel_siswa = 'VIII-D' OR rombel_siswa = 'VIII-E' OR rombel_siswa = 'VIII-F' OR rombel_siswa = 'VIII-G' OR rombel_siswa = 'VIII-H' OR rombel_siswa = 'VIII-I' OR rombel_siswa = 'VIII-J' OR rombel_siswa = 'VIII-K' OR rombel_siswa = 'VIII-L' OR rombel_siswa = 'VIII-M' OR rombel_siswa = 'VIII-N' OR rombel_siswa = 'VIII-O')),0) AS agama_siswa_hindu_viii, IFNULL(sum(a.agama_siswa='Konghucu' AND (rombel_siswa = 'VIII-A' OR rombel_siswa = 'VIII-B' OR rombel_siswa = 'VIII-C' OR rombel_siswa = 'VIII-D' OR rombel_siswa = 'VIII-E' OR rombel_siswa = 'VIII-F' OR rombel_siswa = 'VIII-G' OR rombel_siswa = 'VIII-H' OR rombel_siswa = 'VIII-I' OR rombel_siswa = 'VIII-J' OR rombel_siswa = 'VIII-K' OR rombel_siswa = 'VIII-L' OR rombel_siswa = 'VIII-M' OR rombel_siswa = 'VIII-N' OR rombel_siswa = 'VIII-O')),0) AS agama_siswa_konghucu_viii,
IFNULL(sum(a.agama_siswa='Islam' AND (rombel_siswa = 'IX-A' OR rombel_siswa = 'IX-B' OR rombel_siswa = 'IX-C' OR rombel_siswa = 'IX-D' OR rombel_siswa = 'IX-E' OR rombel_siswa = 'IX-F' OR rombel_siswa = 'IX-G' OR rombel_siswa = 'IX-H' OR rombel_siswa = 'IX-I' OR rombel_siswa = 'IX-J' OR rombel_siswa = 'IX-K' OR rombel_siswa = 'IX-L' OR rombel_siswa = 'IX-M' OR rombel_siswa = 'IX-N' OR rombel_siswa = 'IX-O')),0) AS agama_siswa_islam_ix, IFNULL(sum(a.agama_siswa='Protestan' AND (rombel_siswa = 'IX-A' OR rombel_siswa = 'IX-B' OR rombel_siswa = 'IX-C' OR rombel_siswa = 'IX-D' OR rombel_siswa = 'IX-E' OR rombel_siswa = 'IX-F' OR rombel_siswa = 'IX-G' OR rombel_siswa = 'IX-H' OR rombel_siswa = 'IX-I' OR rombel_siswa = 'IX-J' OR rombel_siswa = 'IX-K' OR rombel_siswa = 'IX-L' OR rombel_siswa = 'IX-M' OR rombel_siswa = 'IX-N' OR rombel_siswa = 'IX-O')),0) AS agama_siswa_protestan_ix, IFNULL(sum(a.agama_siswa='Katolik' AND (rombel_siswa = 'IX-A' OR rombel_siswa = 'IX-B' OR rombel_siswa = 'IX-C' OR rombel_siswa = 'IX-D' OR rombel_siswa = 'IX-E' OR rombel_siswa = 'IX-F' OR rombel_siswa = 'IX-G' OR rombel_siswa = 'IX-H' OR rombel_siswa = 'IX-I' OR rombel_siswa = 'IX-J' OR rombel_siswa = 'IX-K' OR rombel_siswa = 'IX-L' OR rombel_siswa = 'IX-M' OR rombel_siswa = 'IX-N' OR rombel_siswa = 'IX-O')),0) AS agama_siswa_katolik_ix, IFNULL(sum(a.agama_siswa='Buddha' AND (rombel_siswa = 'IX-A' OR rombel_siswa = 'IX-B' OR rombel_siswa = 'IX-C' OR rombel_siswa = 'IX-D' OR rombel_siswa = 'IX-E' OR rombel_siswa = 'IX-F' OR rombel_siswa = 'IX-G' OR rombel_siswa = 'IX-H' OR rombel_siswa = 'IX-I' OR rombel_siswa = 'IX-J' OR rombel_siswa = 'IX-K' OR rombel_siswa = 'IX-L' OR rombel_siswa = 'IX-M' OR rombel_siswa = 'IX-N' OR rombel_siswa = 'IX-O')),0) AS agama_siswa_buddha_ix, IFNULL(sum(a.agama_siswa='Hindu' AND (rombel_siswa = 'IX-A' OR rombel_siswa = 'IX-B' OR rombel_siswa = 'IX-C' OR rombel_siswa = 'IX-D' OR rombel_siswa = 'IX-E' OR rombel_siswa = 'IX-F' OR rombel_siswa = 'IX-G' OR rombel_siswa = 'IX-H' OR rombel_siswa = 'IX-I' OR rombel_siswa = 'IX-J' OR rombel_siswa = 'IX-K' OR rombel_siswa = 'IX-L' OR rombel_siswa = 'IX-M' OR rombel_siswa = 'IX-N' OR rombel_siswa = 'IX-O')),0) AS agama_siswa_hindu_ix, IFNULL(sum(a.agama_siswa='Konghucu' AND (rombel_siswa = 'IX-A' OR rombel_siswa = 'IX-B' OR rombel_siswa = 'IX-C' OR rombel_siswa = 'IX-D' OR rombel_siswa = 'IX-E' OR rombel_siswa = 'IX-F' OR rombel_siswa = 'IX-G' OR rombel_siswa = 'IX-H' OR rombel_siswa = 'IX-I' OR rombel_siswa = 'IX-J' OR rombel_siswa = 'IX-K' OR rombel_siswa = 'IX-L' OR rombel_siswa = 'IX-M' OR rombel_siswa = 'IX-N' OR rombel_siswa = 'IX-O')),0) AS agama_siswa_konghucu_ix
FROM siswa a
JOIN kecamatan b ON a.id_kecamatan = b.id_kecamatan
JOIN sekolah c ON a.id_sekolah = c.id_sekolah
WHERE a.id_sekolah = '$data[id_sekolah]'");
$row = array();
while ($data1 = mysql_fetch_array($sql1)) $row[] = $data1;
foreach ($row as $b){
$agama_siswa_islam_vii = $b[0];
$agama_siswa_protestan_vii = $b[1];
$agama_siswa_katolik_vii = $b[2];
$agama_siswa_buddha_vii = $b[3];
$agama_siswa_hindu_vii = $b[4];
$agama_siswa_konghucu_vii = $b[5];

$agama_siswa_islam_viii = $b[6];
$agama_siswa_protestan_viii = $b[7];
$agama_siswa_katolik_viii = $b[8];
$agama_siswa_buddha_viii = $b[9];
$agama_siswa_hindu_viii = $b[10];
$agama_siswa_konghucu_viii = $b[11];

$agama_siswa_islam_ix = $b[12];
$agama_siswa_protestan_ix = $b[13];
$agama_siswa_katolik_ix = $b[14];
$agama_siswa_buddha_ix = $b[15];
$agama_siswa_hindu_ix = $b[16];
$agama_siswa_konghucu_ix = $b[17];

echo "<td><center>$mpdf->WriteHTML($agama_siswa_islam_vii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_protestan_vii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_katolik_vii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_buddha_vii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_hindu_vii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_konghucu_vii);</center></td>
<th><center>$mpdf->WriteHTML($agama_siswa_islam_vii)+$mpdf->WriteHTML($agama_siswa_protestan_vii)+$mpdf->WriteHTML($agama_siswa_katolik_vii)+$mpdf->WriteHTML($agama_siswa_buddha_vii)+$mpdf->WriteHTML($agama_siswa_hindu_vii)+$mpdf->WriteHTML($agama_siswa_konghucu_vii);?></center></th>";

$sql_umur = mysql_query("SELECT
COUNT(IF(a.umur <=11,1,NULL)) AS umur11,
COUNT(IF(a.umur=12,1,NULL)) AS umur12,
COUNT(IF(a.umur=13,1,NULL)) AS umur13,
COUNT(IF(a.umur=14,1,NULL)) AS umur14,
COUNT(IF(a.umur=15,1,NULL)) AS umur15,
COUNT(IF(a.umur=16,1,NULL)) AS umur16,
COUNT(IF(a.umur>=17,1,NULL)) AS umur17
FROM (SELECT TIMESTAMPDIFF(YEAR, tanggal_lahir, CURDATE())
AS umur
FROM siswa
WHERE (rombel_siswa = 'VII-A' OR rombel_siswa = 'VII-B' OR rombel_siswa = 'VII-C' OR rombel_siswa = 'VII-D' OR rombel_siswa = 'VII-E' OR rombel_siswa = 'VII-F' OR rombel_siswa = 'VII-G' OR rombel_siswa = 'VII-H' OR rombel_siswa = 'VII-I' OR rombel_siswa = 'VII-J' OR rombel_siswa = 'VII-K' OR rombel_siswa = 'VII-L' OR rombel_siswa = 'VII-M' OR rombel_siswa = 'VII-N' OR rombel_siswa = 'VII-O')
AND id_kecamatan = '$data1[id_kecamatan]') a");
$row = array();
while ($data_umur = mysql_fetch_array($sql_umur)) $row[] = $data_umur;
foreach ($row as $c){
$umur11 = $c[0];
$umur12 = $c[1];
$umur13 = $c[2];
$umur14 = $c[3];
$umur15 = $c[4];
$umur16 = $c[5];
$umur17 = $c[6];

echo "<td><center>$mpdf->WriteHTML($umur11);</center></td>
<td><center>$mpdf->WriteHTML($umur12);</center></td>
<td><center>$mpdf->WriteHTML($umur13);</center></td>

<td><center>$mpdf->WriteHTML($umur14);</center></td>
<td><center>$mpdf->WriteHTML($umur15);</center></td>
<td><center>$mpdf->WriteHTML($umur16);</center></td>
<td><center>$mpdf->WriteHTML($umur17);</center></td>
<th><center>$mpdf->WriteHTML($umur11)+$mpdf->WriteHTML($umur12)+$mpdf->WriteHTML($umur13)+$mpdf->WriteHTML($umur14)+$mpdf->WriteHTML($umur15)+$mpdf->WriteHTML($umur16)+$mpdf->WriteHTML($umur17);?></center></th>";

}

echo "</tr>

<tr>
<td><center>VIII</center></td>
<td><center>0</center></td>
<td><center>$mpdf->WriteHTML($bulan_lalu_laki_viii);</center></td>
<td><center>$mpdf->WriteHTML($bulan_lalu_perempuan_viii);</center></td>
<th><center>$mpdf->WriteHTML($bulan_lalu_laki_viii)+$mpdf->WriteHTML($bulan_lalu_perempuan_viii);?></center></th>

<td><center>$mpdf->WriteHTML($keluar_laki_viii);</center></td>
<td><center>$mpdf->WriteHTML($keluar_perempuan_viii);</center></td>
<td><center>$mpdf->WriteHTML($masuk_laki_viii);</center></td>
<td><center>$mpdf->WriteHTML($masuk_perempuan_viii);</center></td>

<td><center>$mpdf->WriteHTML($bulan_ini_laki_viii);</center></td>
<td><center>$mpdf->WriteHTML($bulan_ini_perempuan_viii);</center></td>
<th><center>$mpdf->WriteHTML($bulan_ini_laki_viii)+$mpdf->WriteHTML($bulan_ini_perempuan_viii);</center></th>

<td><center>$mpdf->WriteHTML($agama_siswa_islam_viii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_protestan_viii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_katolik_viii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_buddha_viii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_hindu_viii);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_konghucu_viii);</center></td>
<th><center>$mpdf->WriteHTML($agama_siswa_islam_viii)+$mpdf->WriteHTML($agama_siswa_protestan_viii)+$mpdf->WriteHTML($agama_siswa_katolik_viii)+$mpdf->WriteHTML($agama_siswa_buddha_viii)+$mpdf->WriteHTML($agama_siswa_hindu_viii)+$mpdf->WriteHTML($agama_siswa_konghucu_viii);?></center></th>";

$sql_umur = mysql_query("SELECT
COUNT(IF(a.umur <=11,1,NULL)) AS umur11,
COUNT(IF(a.umur=12,1,NULL)) AS umur12,
COUNT(IF(a.umur=13,1,NULL)) AS umur13,
COUNT(IF(a.umur=14,1,NULL)) AS umur14,
COUNT(IF(a.umur=15,1,NULL)) AS umur15,
COUNT(IF(a.umur=16,1,NULL)) AS umur16,
COUNT(IF(a.umur>=17,1,NULL)) AS umur17
FROM (SELECT TIMESTAMPDIFF(YEAR, tanggal_lahir, CURDATE())
AS umur FROM siswa
WHERE (rombel_siswa = 'VIII-A' OR rombel_siswa = 'VIII-B' OR rombel_siswa = 'VIII-C' OR rombel_siswa = 'VIII-D' OR rombel_siswa = 'VIII-E' OR rombel_siswa = 'VIII-F' OR rombel_siswa = 'VIII-G' OR rombel_siswa = 'VIII-H' OR rombel_siswa = 'VIII-I' OR rombel_siswa = 'VIII-J' OR rombel_siswa = 'VIII-K' OR rombel_siswa = 'VIII-L' OR rombel_siswa = 'VIII-M' OR rombel_siswa = 'VIII-N' OR rombel_siswa = 'VIII-O')
AND id_kecamatan = '$data1[id_kecamatan]') a");
$row = array();
while ($data_umur = mysql_fetch_array($sql_umur)) $row[] = $data_umur;
foreach ($row as $d){
$umur11 = $d[0];
$umur12 = $d[1];
$umur13 = $d[2];
$umur14 = $d[3];
$umur15 = $d[4];
$umur16 = $d[5];
$umur17 = $d[6];

echo "<td><center>$mpdf->WriteHTML($umur11);</center></td>
<td><center>$mpdf->WriteHTML($umur12);</center></td>
<td><center>$mpdf->WriteHTML($umur13);</center></td>

<td><center>$mpdf->WriteHTML($umur14);</center></td>
<td><center>$mpdf->WriteHTML($umur15);</center></td>
<td><center>$mpdf->WriteHTML($umur16);</center></td>
<td><center>$mpdf->WriteHTML($umur17);</center></td>
<th><center>$mpdf->WriteHTML($umur11)+$mpdf->WriteHTML($umur12)+$mpdf->WriteHTML($umur13)+$mpdf->WriteHTML($umur14)+$mpdf->WriteHTML($umur15)+$mpdf->WriteHTML($umur16)+$mpdf->WriteHTML($umur17);</center></th>";

}

echo "</tr>

<tr>
<td><center>IX</center></td>
<td><center>0</center></td>
<td><center>$mpdf->WriteHTML($bulan_lalu_laki_ix);</center></td>
<td><center>$mpdf->WriteHTML($bulan_lalu_perempuan_ix);</center></td>
<th><center>$mpdf->WriteHTML($bulan_lalu_laki_ix)+$mpdf->WriteHTML($bulan_lalu_perempuan_ix);</center></th>

<td><center>$mpdf->WriteHTML($keluar_laki_ix);</center></td>
<td><center>$mpdf->WriteHTML($keluar_perempuan_ix);</center></td>
<td><center>$mpdf->WriteHTML($masuk_laki_ix);</center></td>
<td><center>$mpdf->WriteHTML($masuk_perempuan_ix);</center></td>

<td><center>$mpdf->WriteHTML($bulan_ini_laki_ix);</center></td>
<td><center>$mpdf->WriteHTML($bulan_ini_perempuan_ix);</center></td>
<th><center>$mpdf->WriteHTML($bulan_ini_laki_ix)+$mpdf->WriteHTML($bulan_ini_perempuan_ix);</center></th>

<td><center>$mpdf->WriteHTML($agama_siswa_islam_ix);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_protestan_ix);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_katolik_ix);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_buddha_ix);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_hindu_ix);</center></td>
<td><center>$mpdf->WriteHTML($agama_siswa_konghucu_ix);</center></td>
<th><center>$mpdf->WriteHTML($agama_siswa_islam_ix)+$mpdf->WriteHTML($agama_siswa_protestan_ix)+$mpdf->WriteHTML($agama_siswa_katolik_ix)+$mpdf->WriteHTML($agama_siswa_buddha_ix)+$mpdf->WriteHTML($agama_siswa_hindu_ix)+$mpdf->WriteHTML($agama_siswa_konghucu_ix);?></center></th>";

$sql_umur = mysql_query("SELECT
COUNT(IF(a.umur <=11,1,NULL)) AS umur11,
COUNT(IF(a.umur=12,1,NULL)) AS umur12,
COUNT(IF(a.umur=13,1,NULL)) AS umur13,
COUNT(IF(a.umur=14,1,NULL)) AS umur14,
COUNT(IF(a.umur=15,1,NULL)) AS umur15,
COUNT(IF(a.umur=16,1,NULL)) AS umur16,
COUNT(IF(a.umur>=17,1,NULL)) AS umur17
FROM (SELECT TIMESTAMPDIFF(YEAR, tanggal_lahir, CURDATE())
AS umur
FROM siswa
WHERE (rombel_siswa = 'IX-A' OR rombel_siswa = 'IX-B' OR rombel_siswa = 'IX-C' OR rombel_siswa = 'IX-D' OR rombel_siswa = 'IX-E' OR rombel_siswa = 'IX-F' OR rombel_siswa = 'IX-G' OR rombel_siswa = 'IX-H' OR rombel_siswa = 'IX-I' OR rombel_siswa = 'IX-J' OR rombel_siswa = 'IX-K' OR rombel_siswa = 'IX-L' OR rombel_siswa = 'IX-M' OR rombel_siswa = 'IX-N' OR rombel_siswa = 'IX-O')
AND id_kecamatan = '$data1[id_kecamatan]') a");
$row = array();
while ($data_umur = mysql_fetch_array($sql_umur)) $row[] = $data_umur;
foreach ($row as $e){
$umur11 = $e[0];
$umur12 = $e[1];
$umur13 = $e[2];
$umur14 = $e[3];
$umur15 = $e[4];
$umur16 = $e[5];
$umur17 = $e[6];

echo "<td><center>$mpdf->WriteHTML($umur11);</center></td>
<td><center>$mpdf->WriteHTML($umur12);</center></td>
<td><center>$mpdf->WriteHTML($umur13);</center></td>

<td><center>$mpdf->WriteHTML($umur14);</center></td>
<td><center>$mpdf->WriteHTML($umur15);</center></td>
<td><center>$mpdf->WriteHTML($umur16);</center></td>
<td><center>$mpdf->WriteHTML($umur17);</center></td>
<th><center>$mpdf->WriteHTML($umur11)+$mpdf->WriteHTML($umur12)+$mpdf->WriteHTML($umur13)+$mpdf->WriteHTML($umur14)+$mpdf->WriteHTML($umur15)+$mpdf->WriteHTML($umur16)+$mpdf->WriteHTML($umur17);?></center></th>";

}

echo "</tr>
</tr>";

}
}

echo "</tbody>
</table>";

//////end tabel kedua//////


$html = ob_get_contents();
ob_end_clean();
$mpdf->SetFooter("Dinas Pendidikan Daerah Kabupaten Tapanuli Selatan - SILABUS");
$mpdf->WriteHTML(utf8_encode($html));
ob_end_clean();
$mpdf->Output("report_silabus.pdf", 'I');
exit;
?>
avatar barkah03
@barkah03

33 Kontribusi 9 Poin

Diperbarui 3 tahun yang lalu

2 Jawaban:

<div>pertama,,, coba debuging dulu,,,, coba dengan menjalankan sql nya di mysql langsung,,, apakah bisa atau tidak,,,,<br>jika berhasil,,, coba debuging script nya,,, dengan menghilangkan sebagian element nya (pake //) apakah berhasil atau tidak,,,,<br>lalu,,, coba juga mengganti nama variable nya,,,, dari yang ku lihat,,, $row di panggil berkali2,,, dan lainnya,,,, takut nya ada bentrok atau suatu lainnya,,,, coba di ganti,, misal $row1 atau sejenisnya,,,<br><br>tidak terlalu bisa membantu karna aku ga bisa debuging secara langsung, namun . . . .<br>semoga bisa sedikit membantu ^^</div>

avatar yukari06
@yukari06

137 Kontribusi 66 Poin

Dipost 3 tahun yang lalu

Jawaban Terpilih

<div>sudah berehasil saya tangani untuk permasalahan ini, yaitu dengan menggunakan mysql_fetch_array bukan mysql_fetch_assoc. inisiasi pertiap nilainya dengan array 1 per 1<br><br></div><pre>$sql = mysql_query("SELECT a.*, b.nm_kecamatan AS nm_kecamatan, c.nm_sekolah AS nm_sekolah FROM keadaan_siswa a JOIN kecamatan b ON a.id_kecamatan = b.id_kecamatan JOIN sekolah c ON a.id_sekolah = c.id_sekolah WHERE a.id_sekolah = '$id_sekolah' AND MONTH(tanggal_data) = MONTH(CURRENT_DATE) ORDER BY id_kecamatan ASC"); $row = array(); while ($data = mysql_fetch_array($sql)) $row[] = $data; foreach ($row as $a){ $bulan_lalu_laki_vii = $a[3]; $bulan_lalu_perempuan_vii = $a[4]; $keluar_laki_vii = $a[5]; $keluar_perempuan_vii = $a[6]; $masuk_laki_vii = $a[7]; $masuk_perempuan_vii = $a[8]; $bulan_ini_laki_vii = $a[9]; $bulan_ini_perempuan_vii = $a[10];

							$bulan_lalu_laki_viii = $a[11];
							$bulan_lalu_perempuan_viii = $a[12];
							$keluar_laki_viii = $a[13];
							$keluar_perempuan_viii = $a[14];
							$masuk_laki_viii = $a[15];
							$masuk_perempuan_viii = $a[16];
							$bulan_ini_laki_viii = $a[17];
							$bulan_ini_perempuan_viii = $a[18];
							
							$bulan_lalu_laki_ix = $a[19];
							$bulan_lalu_perempuan_ix = $a[20];
							$keluar_laki_ix = $a[21];
							$keluar_perempuan_ix = $a[22];
							$masuk_laki_ix = $a[23];
							$masuk_perempuan_ix = $a[24];
							$bulan_ini_laki_ix = $a[25];
							$bulan_ini_perempuan_ix = $a[26];
							
							 
								$jumlah_bulan_lalu_vii=$bulan_lalu_laki_vii+$bulan_lalu_perempuan_vii;
								$jumlah_bulan_ini_vii=$bulan_ini_laki_vii+$bulan_ini_perempuan_vii;
								
								$jumlah_bulan_lalu_viii=$bulan_lalu_laki_viii+$bulan_lalu_perempuan_viii;
								$jumlah_bulan_ini_viii=$bulan_ini_laki_viii+$bulan_ini_perempuan_viii;
								
								$jumlah_bulan_lalu_ix=$bulan_lalu_laki_ix+$bulan_lalu_perempuan_ix;
								$jumlah_bulan_ini_ix=$bulan_ini_laki_ix+$bulan_ini_perempuan_ix;&lt;/pre&gt;
avatar barkah03
@barkah03

33 Kontribusi 9 Poin

Dipost 3 tahun yang lalu

Login untuk ikut Jawaban