i am doing a shopping cart.i had a variable $total.when i add 1st product of price 200 i get $total=200 , when i add 2nd product of price 100 i get $total=200100 when i add 3rd product of price 400 i get $total=200100400 . i want to get $total=700. how to fix this problem?
session_start();
$ar20=Db::getInstance()->ExecuteS('SELECT * FROM '._DB_PREFIX_.'price WHERE id="'.$_SESSION['y'].'" AND prodid="'.$row['id_product'].'" ORDER BY size DESC');
for($i=0;$i < count($ar20);$i++)
{
$test=$test+$ar20[$i]['price'];
}
$row['price'] += $test ;
$row['total'] = $row['price'] * intval($row['quantity']);
if 3 products then echo the $row['total'] will get this 100200300
+does an implicit conversion to a numeric value. This might sound like a stupid question, but are you sure you're adding the numbers together in PHP an not in a Javascript code block embedded in a PHP doc?