Im trying to calculate a subtotal and a total from a series of values stored in an array returned from a mysql database.
this i what i have thusfar
while($row = mysql_fetch_array($cart)){
foreach($row AS $key => $value) { $row[$key] = stripslashes($value); }
$id = $row['id'];
$contents = unserialize($row['contents']);
foreach( $contents as $key => $value){
if($key == "price"){$subtotal = $subtotal+$value;}
echo "$key : $value <br />";
}
echo "<br><br><br>";
}
echo "<font color=red>SubTotal $subtotal</font>";
$contents contains an array [name] => super [price] => 65.87 [quantity] => 25
So i need to multiply the price by quantity, and then take that subtotal (per item) and add it in total after the loop