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

Thread: Sum quantities

  1. #1
    Regular Coder
    Join Date
    Apr 2006
    Posts
    154
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Sum quantities

    Greetings!!!

    I have a problem that I haven't discover the solution and I need a help of you!...

    I have a DB table with a quantity field that I update frequently. The table have some registers and I want to see the sum of that quantities of them.

    My situation in this moment:

    PHP Code:
    <? 
                        $sql 
    "select * from cart where session = '$sid'";
                          
    $query query($sql);
                        
    $conta mysql_num_rows($query);
                        for (
    $i=0;$i<$conta;$i++)
                        {
                        
                            
    $arrw mysql_fetch_array($query);
                            
                        
                    
    ?>
                    
                    <td align="right"><h2><a href="carrinho.php" target="_blank">Carrinho</a> - tem <em><? if($arrw["quant"]) echo $arrw["quant"]; else echo "0"?></em> produtos</h2></td>
                
                    
                    <? ?>
    In this case appears a number of phrases as the number of registers that I have update.

    Any sugestion??

  • #2
    New Coder
    Join Date
    Feb 2005
    Posts
    40
    Thanks
    0
    Thanked 0 Times in 0 Posts
    google -> mysql sum

    first link:

    http://www.tizag.com/mysqlTutorial/mysqlsum.php

    have some good examples, you will understend it.

    ps: tenta googlar primeiro poupa-te tempo, em vez de esperares que aqui te deem a resposta.


  •  

    Posting Permissions

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