Advertisement
Guest User

laporan

a guest
Feb 7th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.63 KB | None | 0 0
  1. <?php
  2.  
  3. include "database/koneksi.php";
  4.  
  5. $sql = mysql_query("SELECT * FROM tabel_pinjam ORDER BY id");
  6. $data = array();
  7. while ($row = mysql_fetch_assoc($sql)){
  8. array_push($data, $row);
  9. }
  10.  
  11. $judul = "Data Peminjaman";
  12. $header = array(
  13. array("label"=>"ID", "length"=>5, "align"=>"L"),
  14. array("label"=>"Nama", "length"=>30, "align"=>"L"),
  15. array("label"=>"Kode", "length"=>30, "align"=>"L"),
  16. array("label"=>"Jurusan", "length"=>30, "align"=>"L"),
  17. array("label"=>"Kelas", "length"=>15, "align"=>"L"),
  18. array("label"=>"Judul", "length"=>30, "align"=>"L"),
  19. array("label"=>"Tujuan", "length"=>30, "align"=>"L"),
  20. array("label"=>"Hari/Tanggal", "length"=>24, "align"=>"L"),
  21. array("label"=>"Jam", "length"=>30, "align"=>"L"),
  22. array("label"=>"Jumlah Buku", "length"=>30, "align"=>"L"),
  23. array("label"=>"JK", "length"=>30, "align"=>"L"),
  24. array("label"=>"Status", "length"=>30, "align"=>"L")
  25. );
  26.  
  27. require_once ("laporan/fpdf.php");
  28. $pdf = new FPDF();
  29. $pdf->AddPage();
  30.  
  31. $pdf->Setfont('Arial', 'B', '16');
  32. $pdf->Cell(0,20, $judul, '0', 1, 'C');
  33.  
  34. $pdf->SetFont('Arial', '', '10');
  35. $pdf->SetFillColor(139, 69, 19);
  36. $pdf->SetTextColor(255);
  37. $pdf->SetDrawColor(222, 184, 135);
  38. foreach ($header as $kolom){
  39. $pdf->Cell($kolom['length'], 10, $kolom['label'], 1, '0', $kolom['align'], true);
  40. }
  41. $pdf->Ln();
  42.  
  43. $pdf->SetFillColor(245, 222, 179);
  44. $pdf->SetFillColor(0);
  45. $pdf->SetFont('');
  46. $fill=false;
  47. foreach ($data as $baris){
  48. $i = 0;
  49. foreach ($baris as $cell){
  50. $pdf->Cell($header[$i]['length'], 5, $cell, 1, '0', $kolom['align'], $fill);
  51. $i++;
  52. }
  53. $fill = !$fill;
  54. $pdf->Ln();
  55. }
  56.  
  57. $pdf->Output();
  58.  
  59. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement