That did the trick. However, I’m working on something else and I feel like it is something so simple but I can’t figure it out.
The header text needs to be changed from Total to the person’s name.
This code is what I managed to come up with. This code comes up with the name:
function viewAll() {
global $pdo;
$this->SetFont('Arial', '', 8);
$sql = "SELECT DISTINCT initials FROM salespeople ORDER BY initials";
$stmt = $pdo->prepare($sql);
$stmt->execute();
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
foreach($result as $initials_ary) {
$initials = implode(" ", $initials_ary);
$name = implode(" ", $initials_ary);
//var_dump($name);
$this->AddPage('L', 'Letter', 0);
$this->headerTotals($name);
$this->viewTotals($initials);
}
}
and this code puts it in place:
function headerTotals($name) {
$x = $this->GetX();
$this->SetX(70);
$this->SetFont('Arial', 'B', 11);
$this->Cell(135, 10, $name, 1, 0, 'C');
$this->Ln();
$this->SetX(70);
$this->SetFont('Arial', 'B', 11);
$this->Cell(20, 10, 'Cust. #', 1, 0, 'C');
$this->Cell(70, 10, 'Name', 1, 0, 'C');
$this->Cell(25, 10, 'Ttl. Sales', 1, 0, 'C');
$this->Cell(20, 10, 'Ttl. Comm.', 1, 0, 'C');
$this->Ln();
$this->SetX($x);
}
The problem I’ve got is that it grabs the data, but the table header is now showing the initials of the person rather than the name like this:
If I try to change the query to show the name, the query does not grab any data.
What am I doing wrong?