You can try this:
<?php
require ('fpdf.php');
class PDF extends FPDF
{
// Page header
function Header()
{
$this->SetFont('Arial', 'BI', 20);
$this->Ln(5);
$this->Cell(60);
$this->Cell(190,10,'INCOME REPORT','B',1,'C',0);
// Line break
$this->Ln(5);
}
// Page footer
function Footer() {
// Position at 15 mm from bottom
$this->SetY(-15);
// Set font
$this->SetFont('helvetica', 'I', 8);
// Page number
$this->Cell(0,10,'Page '.$this->PageNo().'/{nb}','T',0,'C',0);
}
}
$pdf = new PDF();
$pdf->AliasNbPages();
$pdf->AddPage();
$pdf->SetFont('arial','B',12);
$result = $db->query("Select
customers.name,
signings1.signstart,
signings1.fname,
signings1.lname,
signings1.city,
signings1.state,
signings1.samount,
signings1.prtamount,
signings1.faxamount
From
customers Inner Join
signings1 On customers.custid = signings1.custid
Where
signings1.pid = 6 And
signings1.done = 1
Order By
customers.name ,
signings1.signstart ");
$current=null;
foreach($result as $key => $income) {
if($current!=$income['name']){ /* PROCEED WHEN THE LAST NAME IS NOT THE SAME WITH THE CURRENT NAME */
$pdf->SetFillColor(0,68,150);
$pdf->SetTextColor (252,252,252);
$pdf->Cell(200,6,'Customer:' . ' ' . $income['name'] ,1,1,'L',1);
//print column titles for the current page
$pdf->SetFillColor(0,68,120);
$pdf->SetTextColor (252,252,252);
$pdf->Cell(30,6,'Date:',1,0,'L',1);
$pdf->Cell(70,6,'Name:',1,0,'L',1);
$pdf->Cell(70,6,'Location:',1,0,'L',1);
$pdf->Cell(30,6,'Amount:',1,1,'L',1);
$current = $income['name'];
} /* END OF IF, LAST NAME IS NOT THE SAME WITH THE CURRENT NAME */
$pdf->SetTextColor (0,0,0);
$total = $income['samount'] + $income['prtamount'] + $income['faxamount'];
$name = $income['fname'] . ' ' .$income['lname'];
$signdate=phpdate($income['signstart']);
$pdf->Cell(30,6,$signdate,1,0,'L',0);
$pdf->Cell(70,6,$name,1,0,'L',0);
$pdf->Cell(70,6,$income['city'],1,0,'L',0);
$pdf->Cell(30,6,$total,1,1,'L',0);
} /* END OF FOREACH */
$pdf->Output();
?>