PDF from Database using FPDF

This solutions came to my mind when i was asked to allow registrar to create student certificates online when they were using the school's local website - similar to TISS certificate generator - i used the free FPDF library which is a PHP class which allows to generate PDF files with pure PHP - the aim is to allow the registrar of school to be able to take the student’s id and course id and generate the student's certificate for a course - the main aim is to show how the class is used in a simple and easy way for use in a small scale - There are two files. The first file, the user inputs the student id and course id and hits create certificate. The file points to the fpdf file that goes and creates a pdf file and displays the certificate
1 answer

PDF from Database using FPDF

First Page is a form to accept student id and course id

Create Certificate

Create Certificate

Student ID:
Course ID:

The second page (certificatereportpdf.php)

define('FPDF_FONTPATH','font/'); // so fpdf knows where the fonts are when it starts writing
require('mysql_table.php'); //on this page, the table selection was already done
class PDF extends PDF_MySQL_Table
function Header() // to make the certificate look nice

$this->Cell(0,6,'Certificate ',0,1,'C');

$this->Cell(0,6,'$date ',0,1,'C');// these are like text boxes

$this->Cell(0,6, 'This is the official Certificate.',0,1,'L');

//Ensure table header is output

//Connect to database


//create a new page
$pdf=new PDF();

//table: specify columns

$pdf->AddCol('studentid',25,'Student ID','C');
$pdf->AddCol('firstname',25,'First Name','L');
$pdf->AddCol('lastname',25,'Last Name','L');
$pdf->AddCol('courseid',25,'Course ID','L');
$pdf->AddCol('result',35,'Result Type','L');


//insert the fields into the columns of the table
$pdf->Table('studentid,firstname,lastname,courseid,result,timestaken from amalgamation where studentid="$studentid" && courseid=$courseid order by ',$prop);

//show it