我有一個關於數組乘法和表格形式顯示的任務,我的老師給我提供了數組形式的數據,並表示將它顯示在表格中形式,也乘以項目**數量和價格**,並在表中顯示....我已經以表格形式顯示數組,但我無法產生數量和價格?有人幫忙嗎?如何在數組上執行計算並以表格形式顯示
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>
<body>
<?php
$ProductsTest = array("1001" => array("Name" => "LCD","Desc" => "Sony","Qty" =>10,"Price" => 2000),
"1002" => array("Name" => "Mouse","Desc" => "Dell","Qty" =>3,"Price" => 300),
"1003" => array("Name" =>"Mouse","Desc" =>"a4Tech","Qty" =>3,"Price" =>300),
"1004" => array("Name" =>"USB","Desc" =>"Kingstton","Qty" =>15,"Price" =>700),
"1005" => array("Name" =>"HeadPhone","Desc" =>"a4Tech","Qty" =>7,"Price" =>3000));
$no_of_ele = count($ProductsTest);
echo '<br><br>';
echo ' <table border="2", bgcolor="white",width="100%">
<tr>
<th>Name</th>
<th>Brand</th>
<th>QTY</th>
<th>price</th>
<th>totalamount</th>
</tr>';
foreach($ProductsTest as $values)
{
echo '<tr>';
foreach($values as $key)
{
echo '<td>'.$key.'</td>';
}
echo '</tr>';
}
echo '</table>';
?>
</body>
</html>
這是我的輸出至今
thnku非常適合我:) –
太棒了!那麼請接受我的回答。 – Naincy