I'm trying to create an attendance table in a month. Please check it
I have this query
select d.Nik,d.tanggal_absensi,d.kodekehadiran,c.NamaSiswa,d.tanggal_absensi,day(d.tanggal_absensi) tanggal from absensi d left join mastersiswa c on d.NIK = c.NIK left join siswa_kelas z on d.Nik = z.NIK left join kelas a on a.ID = z.Kelas where a.ID = '1' and month(d.tanggal_absensi) = '12' GROUP BY d.Nik,d.tanggal_absensi,d.kodekehadiran,c.NamaSiswa,a.Kelas,d.tanggal_absensi,day(d.tanggal_absensi)
with my query i get this result
Nik tanggal_absensi kodekehadiran NamaSiswa tanggal_absensi tanggal
1111 20161218 H Nama A 2016-12-18 18
1111 20161219 I Nama A 2016-12-19 19
123456 20161218 H ADI SURIONO 2016-12-18 18
123456 20161219 H ADI SURIONO 2016-12-19 19
Here is my HTML & PHP
<table width="100%" class="table table-bordered table-striped">
<thead>
<tr align="center">
<th width="6%">No</th>
<th width="19%">Nama</th>
<?php for($x=1;$x<=31;$x++){ ?><th><?php echo $x;?></th> <? } ?>
</tr>
</thead>
<tbody>
<?
$no = 0;
foreach($absensi as $tampil){
$no++;
?>
<tr>
<td><?=$no?></td>
<td><?=$tampil->NamaSiswa;?></td>
<?php for($x=1;$x<=31;$x++){ ?>
<td>
<?php if($tampil->tanggal == $x){echo $tampil->kodekehadiran;} ?>
</td>
<?php } ?>
</tr>
<?php } ?>
</tbody>
</table>
I get this result in my website.
How can i achieve ?
No Nama 1 - 2 - 3 - 4 - 5 - 18 19 - 20 - 21 - 22
1 NAMA A - - - - - H I - - -
2 Nama B - - - - - I H - - -
So, I don't know how to list all day in a month so, i using for with php to create it. Sorry for my bad english.
