format("Y-m-d"); //https://www.youtube.com/watch?v=gNH6NNyhJLk //https://www.youtube.com/watch?v=EYYZFRRdR6A PDF with MySQL database $count = 0; require ('./fpdf.php'); class PDF extends FPDF{ function Header(){ $this->Image('../images/ahg_logo.png',10,10, 25,10, 'PNG','wwww.autohubgroup.com'); } /* function Footer(){ $this->SetY(-25); $this->Image('../images/ahg_logo.png'); } */ } include_once("../../../cfg/conn.php"); $sql ="SELECT * FROM kra_group_division WHERE deleted=0 ORDER BY kra_code ASC"; $myUID = $_GET['id']; $getName = "SELECT * FROM pms_users WHERE id = $myUID LIMIT 1"; $getMyName = mysqli_query($conn,$getName); while($nRow = mysqli_fetch_array($getMyName)){ $fname=$nRow['f_name']; $lname=$nRow['l_name']; $myFName = $fname ." ". $lname; } $pdf = new PDF(); //set margins $pdf->SetMargins(10,25,10); $pdf->AddPage(); //set column size in array format $width_cell = array(20,20,30,120); //set Image //$pdf->Image('../images/ahg_logo.png',10,5, 25,10, 'PNG','wwww.autohubgroup.com'); //background color $pdf->SetFillColor(255,255,255); //use for report title bgcolor $pdf->SetFont('Arial','B',12); $pdf->MultiCell(0,10,"GROUP DIVISION KRA",0,0,'C',true); $pdf->SetFont('Arial','',8, 'landscape'); $pdf->SetFillColor(255,229,252,90); //use for header bgcolor $pdf->SetTextColor(0,0,0,90); $pdf->SetLineWidth(0); $pdf->SetDrawColor(0,0,25); //header start $pdf->Cell($width_cell[0],5,'NO.',1,0,'L',true); $pdf->Cell($width_cell[1],5,'WEIGHT',1,0,'L',true); $pdf->Cell($width_cell[2],5,'KRA CODE',1,0,'L',true); $pdf->Cell($width_cell[3],5,'KRA NAME',1,0,'L',true); $pdf->SetFillColor(255,255,255); //use for body bgcolor $fill=false; //$pdf->Cell(400,200,'Hello Arnel'); $getArea = mysqli_query($conn,$sql); $statRow = mysqli_num_rows($getArea); if($statRow > 0){ while($row = mysqli_fetch_array($getArea)){ $count =$count + 1; $pdf->MultiCell(0,5,"",1,0,'L',$fill); //setup row padding $pdf->Cell($width_cell[0],5,$count,1,0,'L',$fill); $pdf->Cell($width_cell[1],5,$row['weight'],1,0,'L',$fill); $pdf->Cell($width_cell[2],5,$row['kra_code'],1,0,'L',$fill); $pdf->Cell($width_cell[3],5,$row['kra_name'],1,0,'L',$fill); $fill =!$fill; // use code to put alternate color between rows } $pdf->MultiCell(1,25,"",0,0,'L',false); //setup row padding $pdf->Cell(100,0,"_____________________________",0,1,'L',false); $pdf->Cell(100,8,$myFName .' / '. $prfDateX ,0,0,'L',false); } $pdf->Output('my_file.php','I'); ?>