I have a two table joined by a certain order_id, it selects from table number 2 based on table 1. Its working but not selecting the first row of table 2 for example below its return id 6 and 7 leaving 5 whereas they share the same order_id
Table2 structure
Is it my code or its something esle i cant seem to figure out? I am testing this on XAMPP below is my php code
if (isset($_GET['id'])) {
$id = (int)$_GET['id'];
}
$conn = $pdo->open();
try {
$stmt = $conn->prepare("SELECT *, invoice_address.id as invaid, invoice.id as invid FROM invoice_address LEFT JOIN invoice ON invoice.order_id=invoice_address.invoice_no WHERE invoice_address.id= :id");
$stmt->execute(['id' =>$id]);
} catch (Exception $e) {
$_SESSION['error'] = '.......'.$e->getMessage();
}
foreach($stmt as $row){
$output .= '<tr>
<td>'.$row["item_name"].'</td>
<td><small>'.$row["item_no"].'</small></td>
<td>'.$row["qty"].'</td>
<td>R '.$row["price"].'</td>
<td>R '.$row["amount_total"].'</td>
</tr>';
}
echo $output;