...

View Full Version : PHP add up MYSQL values



lamasu
12-12-2010, 02:15 PM
Hey, I've been working on a php webshop for a while but now i've run stuck hoping you guys can help me.

This is my PHP:


THIS IS JUST A PART OF A BIGGER FUNCTIONAL CODE

$price=$row['productPrice'];
echo '<div class="baskitem_price">&euro;';
echo $price;
echo '</div>';

This is my HTML:


<div class="baskitem_total"><span style="color:#06C;">Total amount: </span>&euro;</div>


I've got several baskitem_price divs and now i need a little script in PHP or Javascript that will add up all the baskitem_price divs and display the answer in the baskitem_total div.
Hope you guys can help me.:confused:

djm0219
12-12-2010, 02:53 PM
Do the addition in your PHP code and echo the total in your total div.



<?php
$basket_total += $row['productPrice'];
?>
<div class="baskitem_total"><span style="color:#06C;">Total amount: </span>&euro;<?php echo $basket_total; ?></div>



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum