PWEB - B - Unduh Laporan PDF

Nama : Muhammad Amin
NRP  : 5025201251
Kelas : PWEB - B - 2022


Langkah - langkah:

  1. Download library FPDF versi v1.85 (2022-11-10) pada link ini
  2. Buat sebuah folder baru dengan nama phpfpdf pada C:\xampp\htdocs\phpfpdf
  3. Extract file fpdf185.zip ke folder tersebut
  4. Buat file baru bernama "unduh-file.php" pada directory project
  5. Tambahkan script berikut pada file tersebut:





<?php
require("../phpfpdf/fpdf.php");
include "config.php";
$pdf = new FPDF("l", "mm", "A4");
$pdf->AddPage();
$pdf->SetFont("Times", "B", 16);
$pdf->Cell(272, 7, "Daftar Calon Siswa Baru SMAN 1 Konoha Utara", 0, 1, "C");
$pdf->Cell(272, 7, "", 0, 1, "C");
$query = "SELECT * FROM calon_siswa";
$result = mysqli_query($db, $query);
if ($result) {
$pdf->SetFont("Times", "B", 12);
$pdf->Cell(16, 6, "ID", 1, 0, "C");
// $pdf->Cell(16, 6, "foto", 1, 0, "C");
$pdf->Cell(64, 6, "Nama", 1, 0, "C");
$pdf->Cell(64, 6, "Alamat", 1, 0, "C");
$pdf->Cell(32, 6, "Jenis Kelamin", 1, 0, "C");
$pdf->Cell(32, 6, "Agama", 1, 0, "C");
$pdf->Cell(64, 6, "Sekolah Asal", 1, 1, "C");
$pdf->SetFont("Times", "", 12);
while($siswa = mysqli_fetch_array($result)) {
$pdf->Cell(16, 6, $siswa["id"], 1, 0, "C");
$pdf->Cell(64, 6, $siswa["nama"], 1, 0, "C");
$pdf->Cell(64, 6, $siswa["alamat"], 1, 0, "C");
$pdf->Cell(32, 6, $siswa["jenis_kelamin"], 1, 0, "C");
$pdf->Cell(32, 6, $siswa["agama"], 1, 0, "C");
$pdf->Cell(64, 6, $siswa["sekolah_asal"], 1, 1, "C");
}
$pdf->Output('D', 'Daftar Calon Siswa Baru.pdf');
}
else {
die("Gagal mengakses basis data...");
}
?>
view raw unduh-pdf.php hosted with ❤ by GitHub
Link Repo 

Comments

Popular posts from this blog

Quiz 1 MPPL

ETS MPPL B 2022

MPPL - Tugas 06 Latihan Pembiyaan Proyek