Script untuk menampilkan cetak print

Ini adalah contoh script cara menampilkan data agar bisa di cetak ataupun di simpan dalam bentuk PDF 

<!DOCTYPE html>
<html>
<head>
<title>DATA LAPORAN </title>
</head>
<body>

<center>

<h2>DATA LAPORAN </h2>
<h4>SMK HASAN KAFRAWI</h4>

</center>

<?php 
include 'koneksi.php';
?>

<table border="1" style="width: 100%">
<tr>

<th width="3%">No</th>
<th width="15%">Nama</th>
<th width="15%">Tanggal Lahir</th>
<th width="20%">Alamat</th>
<th width="15">Pekerjaan</th>
<th width="15%">No HP</th>
<th width="15%">Email</th>

</tr>

<?php 
include "koneksi.php";
$no = 1;
$sql=mysql_query("select * from user");
while($user = mysql_fetch_array($sql)){
?>
<tr>
<td><?php echo $no++; ?></td>
<td><?php echo $user['nama']; ?></td>
<td><?php echo $user['tanggallahir']; ?></td>
<td><?php echo $user['alamat']; ?></td>
<td><?php echo $user['pekerjaan']; ?></td>
<td><?php echo $user['nohp']; ?></td>
<td><?php echo $user['email']; ?></td>
</tr>
<?php 
}
?>
</table>

<script>
window.print();
</script>

</body>
</html>

Semoga bermanfaat

Comments

Popular posts from this blog

Soal pilihan ganda dan essay pemrograman web dan perangkat bergerak

SOAL PEMROGRAMAN BERORIENTASI OBJEK (PBO) kelas 12

Soal PBO Pilihan Ganda dan Essay SMT 19