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)
<?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
$date=date(date);
class PDF extends PDF_MySQL_Table
{
function Header() // to make the certificate look nice
{
//Title
$this->SetFont('Arial','',14);
$this->Cell(0,6,'Certificate ',0,1,'C');
$this->Ln(10);
$this->Cell(0,6,'$date ',0,1,'C');// these are like text boxes
$this->Ln(10);
$this->Cell(0,6, 'This is the official Certificate.',0,1,'L');
$this->Ln(16);
//Ensure table header is output
parent::Header();
}
}
//Connect to database
mysql_connect('localhost','root','');
mysql_select_db('studentsdb');
$studentid=$_POST['studentid'];
$courseid=$_POST['courseid'];
$date=date(date);
//create a new page
$pdf=new PDF();
$pdf->Open();
$pdf->AddPage();
//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');
$pdf->AddCol('timestaken',30,'Organization','L');
$prop=array('HeaderColor'=>array(255,150,100),
'color1'=>array(210,245,255),
'color2'=>array(255,255,210),
'padding'=>2);
//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
$pdf->Output();
?>