<!DOCTYPE html>
<html>
<head>
	<title>Export Data Ke Excel </title>
</head>
<body>
	<style type="text/css">
	body{
		font-family: sans-serif;
	}
	table{
		margin: 20px auto;
		border-collapse: collapse;
	}
	table th,
	table td{
		border: 1px solid #3c3c3c;
		padding: 3px 8px;

	}
	a{
		background: blue;
		color: #fff;
		padding: 8px 10px;
		text-decoration: none;
		border-radius: 2px;
	}
	</style>

	<?php
	header("Content-type: application/vnd-ms-excel");
	header("Content-Disposition: attachment; filename=Data Hasil Ujian.xls");
	?>

	<center>
		<h1>Export Data Ke Excel </h1>
	</center>

	<table border="1">
		<tr>
			<th>No</th>
			<th>Nama Ujian</th>
			<th>No Pendaftaran</th>
			<th>Nama Catar</th>
			<th>Passing Score</th>
			<th>Score</th>
			<th>Persentase Score</th>
			<th>Status</th>
			<th>Waktu Submit</th>
		</tr>
		<?php 
		// koneksi database
		$koneksi = mysqli_connect("localhost","poltekbangsby_tpa-nonreg","Aurel@12345","poltekbangsby_tpa-nonreg");
        // $namamapel=$_GET['mapel'];
		// menampilkan data pegawai
		$data = mysqli_query($koneksi,"select * from tpa_nonreg_result");
		$no = 1;
		while($d = mysqli_fetch_array($data)){
		?>
		<tr>
			<td><?php echo $no++; ?></td>
			<td><?php echo $d['nama_ujian']; ?></td>
			<td><?php echo $d['no_daftar']; ?></td>
			<td><?php echo $d['nama']; ?></td>
			<td><?php echo $d['passing_score']; ?></td>
			<td><?php echo $d['score']; ?></td>
			<td><?php echo $d['score_percentage']; ?></td>
			<td><?php echo $d['status']; ?></td>
			<td><?php echo $d['waktu']; ?></td>
		</tr>
		<?php 
		}
		?>
	</table>
</body>
</html>