Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- include "database/koneksi.php";
- $sql = mysql_query("SELECT * FROM tabel_pinjam ORDER BY id");
- $data = array();
- while ($row = mysql_fetch_assoc($sql)){
- array_push($data, $row);
- }
- $judul = "Data Peminjaman";
- $header = array(
- array("label"=>"ID", "length"=>5, "align"=>"L"),
- array("label"=>"Nama", "length"=>30, "align"=>"L"),
- array("label"=>"Kode", "length"=>30, "align"=>"L"),
- array("label"=>"Jurusan", "length"=>30, "align"=>"L"),
- array("label"=>"Kelas", "length"=>15, "align"=>"L"),
- array("label"=>"Judul", "length"=>30, "align"=>"L"),
- array("label"=>"Tujuan", "length"=>30, "align"=>"L"),
- array("label"=>"Hari/Tanggal", "length"=>24, "align"=>"L"),
- array("label"=>"Jam", "length"=>30, "align"=>"L"),
- array("label"=>"Jumlah Buku", "length"=>30, "align"=>"L"),
- array("label"=>"JK", "length"=>30, "align"=>"L"),
- array("label"=>"Status", "length"=>30, "align"=>"L")
- );
- require_once ("laporan/fpdf.php");
- $pdf = new FPDF();
- $pdf->AddPage();
- $pdf->Setfont('Arial', 'B', '16');
- $pdf->Cell(0,20, $judul, '0', 1, 'C');
- $pdf->SetFont('Arial', '', '10');
- $pdf->SetFillColor(139, 69, 19);
- $pdf->SetTextColor(255);
- $pdf->SetDrawColor(222, 184, 135);
- foreach ($header as $kolom){
- $pdf->Cell($kolom['length'], 10, $kolom['label'], 1, '0', $kolom['align'], true);
- }
- $pdf->Ln();
- $pdf->SetFillColor(245, 222, 179);
- $pdf->SetFillColor(0);
- $pdf->SetFont('');
- $fill=false;
- foreach ($data as $baris){
- $i = 0;
- foreach ($baris as $cell){
- $pdf->Cell($header[$i]['length'], 5, $cell, 1, '0', $kolom['align'], $fill);
- $i++;
- }
- $fill = !$fill;
- $pdf->Ln();
- }
- $pdf->Output();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement