<td width="50"><?php 
    echo tgl_db($fetch_tampil['tgl_pinjam']);
    ?>
</td>
									<td><?php 
    echo $fetch_tampil['kd_pinjam'];
    ?>
</td>
									<td><?php 
    echo $fetch_tampil['id_anggota'];
    ?>
</td>
									<td><?php 
    echo $fetch_tampil['nama'];
    ?>
</td>
									<td><?php 
    echo jum_buk($fetch_tampil['kd_pinjam']);
    ?>
</td>
								</tr>
								<?php 
}
?>
					</table>

			<button type="button" class="btn btn-success" onclick="window.print()"> <span class="glyphicon glyphicon-print"></span> Cetak Dokumen </button>
		</center>
	</div>
</body>
</html>
$tgl1 = isset($_GET['awal']) ? $_GET['awal'] : null;
$tgl2 = isset($_GET['akhir']) ? $_GET['akhir'] : null;
$judul = "<strong><h3>Laporan Data Transaksi Peminjaman Per Periode " . tgl_db($tgl1) . " s/d " . tgl_db($tgl2) . "</h3></strong>\n\t\t\t <p>Sistem Informasi perpustakaan AMIK YMI Tegal</p>";
$header = "<table>\n\t\t\t\t<tr>\n\t\t\t\t\t<th>No </th>\n\t\t\t\t\t<th>Tanggal Peminjaman</th>\n\t\t\t\t\t<th>Kode Pinjam</th>\n\t\t\t\t\t<th>ID Anggota</th>\n\t\t\t\t\t<th>Nama</th>\n\t\t\t\t\t<th>Jumlah Pinjam</th>\n\t\t\t\t</tr>";
$query_tampil = mysql_query("SELECT * FROM t_peminjaman JOIN t_anggota ON t_peminjaman.id_anggota = t_anggota.id_anggota\n\t\t\t\t\t\t\t\t\t\t\t\t WHERE tgl_pinjam BETWEEN '{$tgl1}' AND '{$tgl2}'");
//mencari jumlah buku
function jum_buk($param)
{
    $query = mysql_query("SELECT * FROM t_peminjaman JOIN det_pinjam ON t_peminjaman.kd_pinjam = det_pinjam.kd_pinjam \n\t\t\t\t\t\t\t  WHERE t_peminjaman.kd_pinjam = '{$param}'");
    $count = mysql_num_rows($query);
    return $count . " Buku";
}
$content_dalam = "";
$no = 1;
while ($fetch_data = mysql_fetch_array($query_tampil)) {
    $content = "<tr>\n\t\t\t\t\t\t<td>" . $no++ . "</td>\n\t\t\t\t\t\t<td>" . tgl_db($fetch_data['tgl_pinjam']) . "</td>\n\t\t\t\t\t\t<td>" . $fetch_data['kd_pinjam'] . "</td>\n\t\t\t\t\t\t<td>" . $fetch_data['id_anggota'] . "</td>\n\t\t\t\t\t\t<td>" . $fetch_data['nama'] . "</td>\n\t\t\t\t\t\t<td>" . jum_buk($fetch_data['kd_pinjam']) . "</td>\n\t\t\t\t\t</tr>";
    $content_dalam = $content_dalam . "" . $content;
}
$footer = "</table>";
$print_sheet = $judul . "<br>" . $header . "\n" . $content_dalam . "\n" . $footer;
$tgl_sekarang = date("Ymd");
header("Content-type: application/vnd.ms-excel");
header("Content-Disposition: attachment; filename=" . $tgl_sekarang . "Lap_peminjaman.xls");
header("Pragma: no-cache");
header("Expires : 0");
print $print_sheet;
?>
	

<script>
	self.close();