Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2
  1. #1
    New to the CF scene
    Join Date
    Dec 2010
    Posts
    9
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Exclamation PHP add up MYSQL values

    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:
    Code:
    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:
    Code:
    <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.

  • #2
    Senior Coder djm0219's Avatar
    Join Date
    Aug 2003
    Location
    Wake Forest, North Carolina
    Posts
    1,303
    Thanks
    4
    Thanked 204 Times in 201 Posts
    Do the addition in your PHP code and echo the total in your total div.

    PHP Code:
    <?php
    $basket_total 
    += $row['productPrice'];
    ?>
    <div class="baskitem_total"><span style="color:#06C;">Total amount:  </span>&euro;<?php echo $basket_total?></div>
    Dave .... HostMonster for all of your hosting needs

  • Users who have thanked djm0219 for this post:

    lamasu (12-12-2010)


  •  

    Tags for this Thread

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •