This is the screenshot of table order_items
Code
<?php
$aa = "SELECT * FROM `order_items` WHERE `id` = '$id'";
$result= $mysqli->query($aa);
while($ord = $result->fetch_assoc()) {
$bb = "SELECT * FROM `products` WHERE `id` = ".$ord['product_id'];
$results = $mysqli->query($bb);
$obs = $results->fetch_assoc()
?>
<tr>
<td>
<?php echo $obs['name'];?>
</td>
<td>
<?php echo $obs['code'];?>
</td>
<td>
<?php echo $ord['quantity'];?>
</td>
<?php }?>
There are two tables order_items
and products
.
In the table order_items there are different product_id
to the same order_id
.
The above code is working properly if there is one product_id
related to one order_item
but if there are more than one product_id
related to one order_item
then this code is not working.