<?php
session_start();
// memanggil library FPDF
require('dist/fpdf.php');
include 'function.php';
 
$active_event_id = get_active_event_id();
$sql="SELECT * FROM comment_id WHERE event_id = '$active_event_id'";

$pdf = new FPDF('P','mm','A4'); 
$pdf->AddPage();

$pdf->SetFont('Arial','B',14);
$pdf->Cell(200,10,'DAFTAR TAMU',20,20,'C');

$width_cell=array(10,50,20,20,50,40);
$pdf->SetFont('Arial','B',10);

//Background color of header//
$pdf->SetFillColor(193,229,252);

// Header starts /// 
//First header column //
$pdf->Cell($width_cell[0],10,'NO',1,0,'C',true);
//Second header column//
$pdf->Cell($width_cell[1],10,'NAMA',1,0,'C',true);
//Third header column//
$pdf->Cell($width_cell[2],10,'TANGGAL',1,0,'C',true); 
//Fourth header column//
$pdf->Cell($width_cell[3],10,'JAM',1,0,'C',true);
//Third header column//
$pdf->Cell($width_cell[4],10,'TAMU',1,0,'C',true); 
$pdf->Cell($width_cell[5],10,'WHATSAPP',1,1,'C',true); 
//// header ends ///////

$pdf->SetFont('Arial','',10);
//Background color of header//
$pdf->SetFillColor(235,236,236); 
//to give alternate background fill color to rows// 
$fill=false;
$no=1;
/// each record is one row  ///
foreach ($koneksi->query($sql) as $row) {
$pdf->Cell($width_cell[0],10,$no++,1,0,'C',$fill);
$pdf->Cell($width_cell[1],10,$row['nama'],1,0,'L',$fill);
$pdf->Cell($width_cell[2],10,$row['tgl'],1,0,'L',$fill);
$pdf->Cell($width_cell[3],10,$row['jam'],1,0,'C',$fill);
$pdf->Cell($width_cell[4],10,$row['tamu'],1,0,'C',$fill);
$pdf->Cell($width_cell[5],10,$row['whatsapp'],1,1,'C',$fill);
//to give alternate background fill  color to rows//
$fill = !$fill;
}
/// end of records /// 

$pdf->Output();
?>

