This is my php code for echoing contents from database.
<?php
include ("config.php");
$results = $mysqli->query
("SELECT transaction_id FROM orders_list WHERE customer_name = 'Klaudia' ORDER BY id LIMIT 100");
if ($results) {
while($obj = $results->fetch_object()) {
echo '<div id="thisklop">';
echo '<ul class="ulung">Id_cart';
echo '<li>'.$obj->transaction_id.'</li>';
echo '</ul>';
$thisthat=$obj->transaction_id;
$otherresults = $mysqli->query
("SELECT transaction_id, items, quantity, one_product_price FROM orders_history
WHERE transaction_id = '$thisthat'");
if ($otherresults) {
while($obj = $otherresults->fetch_object()) {
echo '<div>';
echo '<ul class="ulung">Products';
echo '<li>'.$obj->items.'</li>';
echo '</ul>';
echo '</div><br>';
echo '<div>';
echo '<ul class="ulung">Quantity';
echo '<li>'.$obj->quantity.'</li>';
echo '</ul>';
echo '</div><br>';
echo '<div>';
echo '<ul class="ulung">Invoices';
echo '<li>'.$obj->one_product_price.'</li>';
echo '</ul>';
echo '</div><br>';
}
}
echo '</div>';
}
}
?>
What I want the result is like this:
[UPDATE TABLE]
-----------------------------------------------------------------------
id_cart products quantity invoices status
-----------------------------------------------------------------------
this 2 $20
0001 that 1 $20 pending
those 2 $20
-----------------------------------------------------------------------
Total Invoices: $60
-----------------------------------------------------------------------
this 2 $20
0002 that 1 $20 approved
those 2 $20
-----------------------------------------------------------------------
Total Invoices: $60
From the table above, the id_cart is in looping, and then inside the id_cart there are also content which are in looping.
I am stuck on the structure I am echoing it. The structure is in a mess