This is my code:
<?php
$stmt = $pdo->prepare("
SELECT valueA, 'TEXT' AS valueAA FROM tableA
UNION ALL
SELECT valueB, 'TEXT2' FROM tableB;
");
$stmt->execute();
$points = $stmt->fetchAll();
foreach($rows as $row):
$valueA = htmlentities($row['valueA']);
$valueAVAR = number_format($valueA);
?>
<div><?php echo $valueAA . $valueAVAR; ?></div>
<?php endforeach; ?>
This is the unwanted result I am getting:
valueA
valueB
This is the result I want:
TEXTvalueA
TEXT2valueB
So basically, my code is not echoing out the word TEXT
before valueA
and valueB
as it should based on my SQL statement. Can you please help me rewrite my code so TEXT
can get echoed out? Thank you
EDIT: Sample of tableA
:
valAid (int11) | valueA (int11)
1 | 100
tableB
:
valBid (int11) | valueB (int11)
2 | 200