My Sql Table
+------------+---------+
| name | price |
+------------+---------+
| A | 70 |
+------------+---------+
| B | 70 |
+------------+---------+
I create a pdf with TCPDF:
$pdo = $db->prepare("SELECT * FROM table");
$pdo->execute();
while ($row = $pdo->fetch(PDO::FETCH_ASSOC)) {
$result += $row['price'];
}
$html = '
<table><tr><th>'.$result.'</th></tr></table>'
;
I expect the result to be 140
, but I get an error message:
Notice: Undefined variable: result
TCPDF ERROR: Some data has already been output, can't send PDF file
Note: If I remove the +
sign. The pdf is created without errors and I get the result 70
.