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,5, 25,10, 'PNG','wwww.autohubgroup.com'); } /* function Footer(){ $this->SetY(-25); $this->Image('../images/ahg_logo.png'); } */ } include_once("../../../cfg/conn.php"); include ("../functions/users.php"); $sql ="SELECT * FROM `pms_unit_tbl` WHERE deleted=0 ORDER BY unit_name 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,20,10); $pdf->AddPage('P'); //SET //set column size in array format $width_cell = array(20,20,20,50,80); //=190 $height_cell= 7; //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,6,"LIST OF SECTIONS",0,0,'L',true); $pdf->SetFont('Arial','',8, 'landscape'); $pdf->SetFillColor(70, 70, 68 ,0); //use for header bgcolor $pdf->SetTextColor(255,255,255,90); $pdf->SetLineWidth(0); $pdf->SetDrawColor(0,0,25); //header start $pdf->Cell($width_cell[0],$height_cell,'ID',1,0,'L',true); $pdf->Cell($width_cell[1],$height_cell,'DEPT',1,0,'L',true); $pdf->Cell($width_cell[2],$height_cell,'CODE',1,0,'L',true); $pdf->Cell($width_cell[3],$height_cell,'SECTION NAME',1,0,'L',true); $pdf->Cell($width_cell[4],$height_cell,'DESCRIPTION',1,0,'L',true); $pdf->SetFillColor(255,255,255,0); //use for header bgcolor $pdf->SetTextColor(0,0,0,90); $fill=false; //$pdf->Cell(400,200,'Hello Arnel'); $getArea = mysqli_query($conn,$sql); $statRow = mysqli_num_rows($getArea); while($row = mysqli_fetch_array($getArea)){ $count =$count + 1; $deptID = $row['dept_id']; $pdf->MultiCell(0,$height_cell,"",1,0,'L',$fill); //setup row padding $pdf->Cell($width_cell[0],$height_cell,$count,1,0,'L',$fill); $pdf->Cell($width_cell[1],$height_cell,getDepartmentName($deptID)[0],1,0,'L',$fill); $pdf->Cell($width_cell[2],$height_cell,$row['unit_code'],1,0,'L',$fill); $pdf->Cell($width_cell[3],$height_cell,$row['unit_name'],1,0,'L',$fill); $pdf->Cell($width_cell[4],$height_cell,$row['unit_desc'],1,0,'L',$fill); $fill =!$fill; // use code to put alternate color between rows } $pdf->MultiCell(1,25,"",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'); ?>