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 vts_dealerships WHERE deal_status=1 ORDER BY deal_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,20,10); $pdf->AddPage('P'); //SET //set column size in array format $width_cell = array(20,25,25,120); //=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 DEALERS/BRANCHES",0,0,'C',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,'COMPANY',1,0,'L',true); $pdf->Cell($width_cell[2],$height_cell,'CODE',1,0,'L',true); $pdf->Cell($width_cell[3],$height_cell,'NAME',1,0,'L',true); $pdf->SetFillColor(255,255,255,0); //use for header bgcolor $pdf->SetTextColor(0,0,0,90); $fill=true; //$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,$height_cell,"",1,0,'L',$fill); //setup row paddinggetCompanyName $pdf->Cell($width_cell[0],$height_cell,$count,1,0,'L',$fill); $pdf->Cell($width_cell[1],$height_cell,getCompanyNameSub($row['comp_id'])[1],1,0,'L',$fill); $pdf->Cell($width_cell[2],$height_cell,$row['deal_code'],1,0,'L',$fill); $pdf->Cell($width_cell[3],$height_cell,$row['deal_name'],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'); ?>