Hi,
The problem was getting the tutorials to run and basically setting it up.
All I had to do was was include the FPDF.php file at the top of the page which uses this fpdf class.
<?php
include_once $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/magicquotes.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/access.inc.php';
require_once $_SERVER['DOCUMENT_ROOT'] . '/artgibney/fpdf17/fpdf.php';
if (!userIsLoggedIn())
{
include '../login.html.php';
exit();
}
if (!userHasRole('Content Editor'))
{
$error = 'Only Content Editors may access this page.';
include '../accessdenied.html.php';
exit();
}
if (isset($_GET['pdf']))
{
class PDF extends FPDF
{
function FancyTable($header,$teachingpts)
{
// Colors, line width and bold font
$this->SetFillColor(103,184,227);
$this->SetTextColor(255);
$this->SetDrawColor(128,0,0);
$this->SetLineWidth(.3);
$this->SetFont('','B');
// Header
$w = array(40, 40, 45);
for($i=0;$i<count($header);$i++)
$this->Cell($w[$i],7,$header[$i],1,0,'C',true);
$this->Ln();
// Color and font restoration
$this->SetFillColor(190,216,232);
$this->SetTextColor(0);
$this->SetFont('');
// Data
$fill = false;
foreach(array_reverse($teachingpts) as $row)
{
$this->Cell($w[0],6,$row['tp'],'LR',0,'L',$fill);
$this->Cell($w[1],6,$row['code'],'LR',0,'L',$fill);
$this->Cell($w[2],6,$row['currno'],'LR',0,'L',$fill);
$this->Ln();
$fill = !$fill;
}
// Closing line
$this->Cell(array_sum($w),0,'','T');
}
}
include $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/db.inc.php';
try
{
$result = $pdo->query('SELECT id, tp, code, currno FROM teachingpts');
}
catch (PDOException $e)
{
$error = 'Error fetching list of teachingpoints.';
include 'error.html.php';
exit();
}
foreach ($result as $row)
{
$teachingpts[] = array('id' => $row['id'], 'tp' => $row['tp'], 'code' => $row['code'], 'currno' => $row['currno']);
}
$pdf = new PDF();
// Column headings
$header = array('Teaching Pts', 'Code', 'Currno');
$pdf->SetFont('Arial','',10);
$pdf->AddPage();
$pdf->FancyTable($header,$teachingpts);
$pdf->Output();
exit();
}
//the following creates an array called topics[] and populates it with the topics for display.
include $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/db.inc.php';
try
{
$result = $pdo->query('SELECT id, tp, code, currno FROM teachingpts');
}
catch (PDOException $e)
{
$error = 'Error fetching list of teacgingpoints.';
include 'error.html.php';
exit();
}
foreach ($result as $row)
{
$teachingpts[] = array('id' => $row['id'], 'tp' => $row['tp'], 'code' => $row['code'], 'currno' => $row['currno']);
}
include 'searchform.html.php';
where the HTML file a just a hyper link which sends an empty variable ‘pdf’ using $_GET
searchform.html.php
<?php include_once $_SERVER['DOCUMENT_ROOT'] . '/artgibney/includes/helpers.inc.php'; ?>
<!DOCTYPE html>
<html lang="en">
<head>
<style>
table,th,td
{
border:1px solid black;
border-collapse:collapse;
}
th, td
{
padding:6px;
}
td { width: 50px; overflow: hidden; }
</style>
<meta charset="utf-8">
</head>
<body>
<p><a href="?pdf">Generate a pdf document.</a></p>
</body>
</html>
Thanks,
Shane