Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- //koneksi ke database
- include "config.php";
- //akhir koneksi
- //Queri untuk Menampilkan data
- $query ="SELECT * FROM inbox";
- $db_query = mysql_query($query) or die("Query gagal");
- //Variabel untuk iterasi
- $i = 0;
- //Mengambil nilai dari query database
- while($data=mysql_fetch_array($db_query))
- {
- $cell[$i][0] = $data[0];
- $cell[$i][1] = $data['ReceivingDateTime'];
- $cell[$i][2] = $data['SenderNumber'];
- $cell[$i][3] = $data['Processed'];
- $cell[$i][4] = $data[4];
- $cell[$i][5] = $data[5];
- $cell[$i][6] = $data[6];
- $cell[$i][7] = $data[7];
- $cell[$i][8] = $data[8];
- $i++;
- }
- require('../libs/fpdf/fpdf.php');
- class PDF extends FPDF
- {
- //Fungsi Untuk Membuat Header
- function Header()
- {
- //Logo
- $this->Image('php_logo.jpg',1,0,'L');
- //Arial bold 15
- $this->SetFont('Arial','B',5);
- //pindah ke posisi ke tengah untuk membuat judul
- $this->Cell(0);
- //pindah baris
- $this->Ln(4);
- //buat garis horisontal
- //$this->Line(10,25,200,25);
- }
- //Fungsi Untuk Membuat Footer
- function Footer()
- {
- //Position at 1.5 cm from bottom
- $this->SetY(23);
- //Arial italic 8
- $this->SetFont('Arial','I',8);
- //Page number
- $this->Cell(0,10,'page of : '.$this->PageNo(),0,0,'L');
- }
- }
- $pdf = new PDF('P','cm','A4');
- $pdf->Open();
- $pdf->AddPage();
- $pdf->SetFont("Arial","B",12);
- //$pdf->Cell(18,1,'LAPORAN DATA SMS INBOX','LRTB',0,'C');
- //$pdf->Ln();
- $pdf->Cell(1,1,'No','LRTB',0,'C');
- $pdf->Cell(5,1,'tanggal','LRTB',0,'C');
- $pdf->Cell(6,1,'Pengirim','LRTB',0,'C');
- $pdf->Cell(6,1,'Status','LRTB',0,'C');
- $pdf->Ln();
- $pdf->SetFont('Times','',10);
- for($j=0;$j<$i;$j++)
- {
- //menampilkan data dari hasil query database
- $pdf->Cell(1,1,$j+1,'LBTR',0,'C');
- $pdf->Cell(5,1,$cell[$j][1],'LBTR',0,'C');
- $pdf->Cell(6,1,$cell[$j][2],'LBTR',0,'C');
- $pdf->Cell(6,1,$cell[$j][3],'LBTR',0,'C');
- $pdf->Ln();
- }
- //menampilkan output berupa halaman PDF
- $pdf->Output();
- ?>
Advertisement
Add Comment
Please, Sign In to add comment