Discover Habbo's history
Treat yourself with a Secret Santa gift.... of a random Wiki page for you to start exploring Habbo's history!
Happy holidays!
Celebrate with us at Habbox on the hotel, on our Forum and right here!
Join Habbox!
One of us! One of us! Click here to see the roles you could take as part of the Habbox community!


Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default Just a quick PHP question....

    Hey,

    How would I go about adding the values of a field fetched from a database?

    Example:

    I fetch all `total` fields from a table so I have:

    450
    560
    ect...

    How would I add every value together?

    450+560

    I want to be able to add the values together as I know they will be numeric.

    Thanks.

    Lew.
    Last edited by LMS16; 10-08-2010 at 09:57 AM.
    Im not here to be loved, I love to be hated :-}


  2. #2
    Join Date
    Nov 2006
    Location
    Narrich
    Posts
    5,687
    Tokens
    0
    Habbo
    Jamesy...

    Latest Awards:

    Default

    you could use the SQL sum function: http://www.techonthenet.com/sql/sum.php
    Ex-janitor. Might pop in from time to time, otherwise you can grab all my information from http://jamesy.me.uk/

  3. #3
    Join Date
    Sep 2009
    Location
    Hull
    Posts
    827
    Tokens
    0

    Latest Awards:

    Default

    I got it working

    Needed to do this:


    PHP Code:
    $carTotalyone mysql_fetch_array(mysql_query("SELECT SUM(totalCost) AS 'totalC' FROM totals WHERE carID=$ided AND totalYear=1"));

    echo 
    $carTotalyone['totalC']; 
    Im not here to be loved, I love to be hated :-}


Posting Permissions

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