I am using FPDF to tell teachers about over due books. The output displays a department, book number and last name. How can I force a page break when the department name changes.
The Problem: I need to access Department and do a test to see if the value is different from the previous one. I do not know how to access Department to do a test and if different innate a page break.
This a code segment:
class
PDF extends PDF_MySQL_Table
{
function Header()
{
$currentDate = date("n/j/Y");
$this->SetFont('Arial','',18);
$this->Cell(0,6,'Over Due List',0,1,'C');
$this->SetFont('Arial','',12);
$this->Cell(0,6,'(Title Left Out for Privacy)',0,1,'C');
$this->SetFont('Arial','',12);
$this->Cell(0,6, ' Date: ' .$currentDate,0,1,'C');
$this->Ln(10);
// Ensure table header is printed
parent::Header();
}
function Footer()
{
// Position at 1.5 cm from bottom
$this->SetY(-15);
// Arial italic 8
$this->SetFont('Arial','I',8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}',0,0,'C');
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
pdf->AddPage();
$pdf->AddCol('Department',40,'Department','C');
$pdf->AddCol('LastName',60,'Last Name','C');
$pdf->AddCol('bookid',20,'Material#','L');
$pdf->AddCol('loandate',25,'Due Date','C');
//------------
//**********
$pdf->Table($link,"SELECT Mbook.BOOKNUM,
Mbook.TITLE,
Eloans.bookid,
Eloans.loandate,
Eloans.borroid,
people.Borronum,
people.FirstName,
people.LastName,
people.Department
FROM(
Mbook
INNER JOIN Eloans ON Mbook.BOOKNUM = Eloans.bookid
LEFT JOIN people ON Eloans.borroid = people.Borronum)
order by People.Department Desc");
$pdf->Output();
?>