SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Adding DB Values together

    I pull some info out of my DB and store it in a variable called $Price if the user has more than 1 item stored in the DB i want to add the values together, can someone please help.

    Thanks in advance
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"

  2. #2
    SitePoint Evangelist -Oz-'s Avatar
    Join Date
    Nov 2001
    Location
    Phoenix, AZ, USA
    Posts
    406
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    in php you could do:
    PHP Code:
    $price=$price $row['price'
    where you're fetching an array of the mysql results called row.

    In mysql you could:
    Code:
    SELECT sum(price) FROM table WHERE user='$user_id'
    Oz
    GamersMark - On Target Gaming
    OzTheory - Programming and Web Solutions
    AmIBlocked - Check if you've been blocked on IM

  3. #3
    SitePoint Wizard
    Join Date
    Dec 2004
    Location
    At My Desk!!
    Posts
    1,642
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    im in your dept, thx.

    had to change the mysql code a little to this:

    PHP Code:
    $Result1 mysql_query("SELECT sum(Price) as Price FROM shoppinglist WHERE UserId = '" $_SESSION['UserId'] . "'"); 
    as you can see i have added "as Price"

    Thanks again
    "Am I the only one doing ASP.NET in Delphi(Pascal)?"


Bookmarks

Posting Permissions

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