Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //error_reporting(0);
- include "../inc.koneksidb.php";
- #ambil data
- $sql = "SELECT * FROM analisa_hasil ORDER BY id";
- $qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
- $data=array();
- while ($row = mysql_fetch_assoc($qry)) {
- array_push($data, $row);
- }
- #setting judul laporan
- $judul = "LAPORAN DATA HASIL KONSULTASI SISWA";
- $judul1 =" SMP Muhammadiyah 1 Weleri";
- $judul2 =" Jl. Bahari No 319 Weleri";
- $header = array (
- array("label"=>"ID", "length"=>10, "align"=>"L"),
- array("label"=>"NIS", "length"=>20, "align"=>"L"),
- array("label"=>"NAMA", "length"=>50, "align"=>"L"),
- array("label"=>"KELAS", "length"=>30, "align"=>"L"),
- array("label"=>"KELAMIN", "length"=>30, "align"=>"L"),
- array("label"=>"ID PERMASALAHAN", "length"=>40, "align"=>"L"),
- array("label"=>"ALAMAT IP", "length"=>40, "align"=>"L"),
- array("label"=>"TANGGAL KONSUL", "length"=>60, "align"=>"L")
- );
- #librari FPDF
- require_once ("fpdf/fpdf.php");
- $pdf = new FPDF('L','mm', array(216, 330));
- $pdf->AddPage();
- #tampilkan judul lap
- $pdf->SetFont('Arial','B','14');
- $pdf->Cell(0,4, $judul, '0', 1, 'C');
- $pdf->SetFont('Arial','B','12');
- $pdf->Cell(0,6, $judul1, '0', 1, 'C');
- $pdf->SetFont('Arial','','8');
- $pdf->Cell(0,4, $judul2, '0', 1, 'C');
- $pdf->SetFont('Arial','','8');
- $pdf->Cell(0,6,'=========================================================
- ==================================================================
- ==================================================================','0', 1, 'C');
- #buat header tabel
- $pdf->SetFont('Arial','','10');
- $pdf->SetFillColor(255,0,0);
- $pdf->SetTextColor(255);
- $pdf->SetDrawColor(128,0,0);
- foreach ($header as $kolom) {
- $pdf->Cell($kolom['length'], 5, $kolom['label'], 1, '0',$kolom['align'], true);
- }
- $pdf->Ln();
- #tampilkan data tabelnya
- $pdf->SetFillColor(224,235,255);
- $pdf->SetTextColor(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();
- }
- #output file PDF
- ob_end_clean();
- $pdf->Output();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement