Advertisement
cdsatrian

generate repeort fpdf

Feb 14th, 2017
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.15 KB | None | 0 0
  1. <?php
  2. //error_reporting(0);
  3. include "../inc.koneksidb.php";
  4. #ambil data
  5. $sql = "SELECT * FROM analisa_hasil ORDER BY id";
  6. $qry = mysql_query($sql, $koneksi) or die ("SQL Error".mysql_error());
  7. $data=array();
  8. while ($row = mysql_fetch_assoc($qry)) {
  9.     array_push($data, $row);
  10. }
  11. #setting judul laporan
  12. $judul = "LAPORAN DATA HASIL KONSULTASI SISWA";
  13. $judul1 =" SMP Muhammadiyah 1 Weleri";
  14. $judul2 =" Jl. Bahari No 319 Weleri";
  15. $header = array (
  16.     array("label"=>"ID", "length"=>10, "align"=>"L"),
  17.     array("label"=>"NIS", "length"=>20, "align"=>"L"),
  18.     array("label"=>"NAMA", "length"=>50, "align"=>"L"),
  19.     array("label"=>"KELAS", "length"=>30, "align"=>"L"),
  20.     array("label"=>"KELAMIN", "length"=>30, "align"=>"L"),
  21.     array("label"=>"ID PERMASALAHAN", "length"=>40, "align"=>"L"),
  22.     array("label"=>"ALAMAT IP", "length"=>40, "align"=>"L"),
  23.     array("label"=>"TANGGAL KONSUL", "length"=>60, "align"=>"L")
  24. );
  25. #librari FPDF
  26. require_once ("fpdf/fpdf.php");
  27. $pdf = new FPDF('L','mm', array(216, 330));
  28. $pdf->AddPage();
  29. #tampilkan judul lap
  30. $pdf->SetFont('Arial','B','14');
  31. $pdf->Cell(0,4, $judul, '0', 1, 'C');
  32. $pdf->SetFont('Arial','B','12');
  33. $pdf->Cell(0,6, $judul1, '0', 1, 'C');
  34. $pdf->SetFont('Arial','','8');
  35. $pdf->Cell(0,4, $judul2, '0', 1, 'C');
  36. $pdf->SetFont('Arial','','8');
  37. $pdf->Cell(0,6,'=========================================================
  38. ==================================================================
  39. ==================================================================','0', 1, 'C');
  40. #buat header tabel
  41. $pdf->SetFont('Arial','','10');
  42. $pdf->SetFillColor(255,0,0);
  43. $pdf->SetTextColor(255);
  44. $pdf->SetDrawColor(128,0,0);
  45. foreach ($header as $kolom) {
  46.     $pdf->Cell($kolom['length'], 5, $kolom['label'], 1, '0',$kolom['align'], true);
  47. }
  48. $pdf->Ln();
  49. #tampilkan data tabelnya
  50. $pdf->SetFillColor(224,235,255);
  51. $pdf->SetTextColor(0);
  52. $pdf->SetFont('');
  53. $fill=false;
  54. foreach ($data as $baris) {
  55.     $i = 0;
  56.     foreach ($baris as $cell) {
  57.         $pdf->Cell($header[$i]['length'], 5, $cell, 1, '0',$kolom['align'], $fill);
  58.         $i++;  
  59.     }
  60.     $fill = !$fill;
  61.     $pdf->Ln();
  62. }
  63. #output file PDF
  64. ob_end_clean();
  65. $pdf->Output();
  66. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement