السلام عليكم
أخباركم ؟؟ في هذا الكود استخدمت while مع each ،،، ولكن كيف يمكن ان نتمم عملية الجمع ،،
<?php
$items=array(0=>array('Item'=>'Tea','Price'=>'1.250','Quantity'=>'3'),
1=>array('Item'=>'Coffee','Price'=>'2.5','Quantity'=>'5'),
2=>array('Item'=>'Rice','Price'=>'5','Quantity'=>'1'));
echo"<table border=3 width=400 bgcolor=lightgreen align=center>";
echo"<tr><th align=center>Item</th>
<th align=center>Price</th>
<th align=center>Quantity</th>
<th align=center>Total</th>
</tr>";
$gtotal=0;
while($myarray=each($items))
{
$total=$v[Quantity]* $v[Price];//Count total for the Current Item
$gtotal += $total; //Calculate the Grand Total
echo"<tr><td align=center>{$myarray[1]['Item']}</td>
<td align=center>{$myarray[1]['Price']}</td>
<td align=center>{$myarray[1]['Quantity']}</td>
<td align=center>$total</td>
</tr>";
}
echo"<tr><th colspan=3 align=left>Total</th><th>$gtotal</th> </tr>";
echo "</table>";
?>