<?php
require_once("dbcontroller.php");
$db_handle = new DBController();
$result = $db_handle->runQuery("SELECT employees.id,employees.first_name,employees.phone,employees.pco_number,employees.driver_photo,employees.address,employees.post_code,vehicles.mot_date,vehicles.reg
FROM employees
JOIN vehicles on vehicles.driver_id=employees.id");
$header = $db_handle->runQuery("SELECT `COLUMN_NAME` 
FROM `INFORMATION_SCHEMA`.`COLUMNS` 
WHERE `TABLE_SCHEMA`='ezycab' 
    AND `TABLE_NAME`='employees'");

require('../pdf_demo/fpdf.php');
$pdf = new FPDF();
$pdf->AddPage('L','A4');
$pdf->SetFont('Arial','B',12);
$count=count($header);
/**/
echo '<pre>';
print_r($header);
echo '</pre>';
//echo $count;
echo $header[0]['COLUMN_NAME'];
exit;		
 
for ($x = 0; $x <5; $x++) {
    $pdf->Cell(40,12,$header[$x]['COLUMN_NAME'],1);
} 
/*
foreach($header as $heading) {
	foreach($heading as $column_heading)
		$pdf->Cell(40,12,$column_heading,1);
}
*/
echo '<pre>';
print_r($result);

echo '</pre>';
echo $result[0]['first_name'];
exit;

for ($x = 0; $x <5; $x++) {
    $pdf->Cell(40,12,$result[$x]['id'],1);
	
	$pdf->Ln();
	$pdf->Cell(40,12,$result[$x]['first_name'],1);
	$pdf->Ln();
} 

/*
foreach($result as $row) {
	$pdf->SetFont('Arial','',12);	
	$pdf->Ln();
	foreach($row as $column)
		$pdf->Cell(40,12,$column,1);
}
*/
$pdf->Output();
?>