mqnoy

laporan bentuk pdf

Apr 16th, 2014
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.90 KB | None | 0 0
  1. <?php
  2. //koneksi ke database
  3. include "config.php";
  4. //akhir koneksi
  5.  
  6. //Queri untuk Menampilkan data
  7. $query ="SELECT * FROM inbox";
  8. $db_query = mysql_query($query) or die("Query gagal");
  9. //Variabel untuk iterasi
  10. $i = 0;
  11. //Mengambil nilai dari query database
  12. while($data=mysql_fetch_array($db_query))
  13. {
  14. $cell[$i][0] = $data[0];
  15. $cell[$i][1] = $data['ReceivingDateTime'];
  16. $cell[$i][2] = $data['SenderNumber'];
  17. $cell[$i][3] = $data['Processed'];
  18. $cell[$i][4] = $data[4];
  19. $cell[$i][5] = $data[5];
  20. $cell[$i][6] = $data[6];
  21. $cell[$i][7] = $data[7];
  22. $cell[$i][8] = $data[8];
  23. $i++;
  24. }
  25. require('../libs/fpdf/fpdf.php');
  26.  
  27. class PDF extends FPDF
  28. {
  29. //Fungsi Untuk Membuat Header
  30. function Header()
  31. {
  32.  
  33.    //Logo
  34.         $this->Image('php_logo.jpg',1,0,'L');
  35.         //Arial bold 15
  36.         $this->SetFont('Arial','B',5);
  37.         //pindah ke posisi ke tengah untuk membuat judul
  38.         $this->Cell(0);
  39.         //pindah baris
  40.         $this->Ln(4);
  41.         //buat garis horisontal
  42.         //$this->Line(10,25,200,25);
  43. }
  44.  
  45. //Fungsi Untuk Membuat Footer
  46. function Footer()
  47. {
  48.     //Position at 1.5 cm from bottom
  49.     $this->SetY(23);
  50.     //Arial italic 8
  51.     $this->SetFont('Arial','I',8);
  52.     //Page number
  53.     $this->Cell(0,10,'page of : '.$this->PageNo(),0,0,'L');
  54. }
  55. }
  56.  
  57. $pdf = new PDF('P','cm','A4');
  58. $pdf->Open();
  59. $pdf->AddPage();
  60. $pdf->SetFont("Arial","B",12);
  61. //$pdf->Cell(18,1,'LAPORAN DATA SMS INBOX','LRTB',0,'C');
  62. //$pdf->Ln();
  63. $pdf->Cell(1,1,'No','LRTB',0,'C');
  64. $pdf->Cell(5,1,'tanggal','LRTB',0,'C');
  65. $pdf->Cell(6,1,'Pengirim','LRTB',0,'C');
  66. $pdf->Cell(6,1,'Status','LRTB',0,'C');
  67. $pdf->Ln();
  68.  
  69. $pdf->SetFont('Times','',10);
  70. for($j=0;$j<$i;$j++)
  71. {
  72. //menampilkan data dari hasil query database
  73. $pdf->Cell(1,1,$j+1,'LBTR',0,'C');
  74. $pdf->Cell(5,1,$cell[$j][1],'LBTR',0,'C');
  75. $pdf->Cell(6,1,$cell[$j][2],'LBTR',0,'C');
  76. $pdf->Cell(6,1,$cell[$j][3],'LBTR',0,'C');
  77.  
  78. $pdf->Ln();
  79. }
  80. //menampilkan output berupa halaman PDF
  81. $pdf->Output();
  82. ?>
Advertisement
Add Comment
Please, Sign In to add comment