這是我的PHP代碼,用於回顯數據庫中的內容。在回聲多重循環的結構中堆棧
<?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>';
}
}
?>
我想要的結果是什麼樣的:
[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
從上面的表中,id_cart在循環,然後id_cart裏面有也是循環中的內容。
我被困在結構上,我在迴應它。其結構是在一個爛攤子
你的意思是卡住了,而不是堆棧? – Jake 2014-11-03 07:28:17