SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: MySQL SELECT

  1. #1
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL SELECT

    Hi,

    This is some script I have written:

    PHP Code:
    print "<br><br>Your Total Earnings Are: ";
        
    mysql_connect('$server''$username''$password') or die ("Database CONNECT Error"); 
        
    $set mysql_db_query($database"select SUM(payment) from sales where refid = '$valid_user'") or die ("Database INSERT Error"); 
        } 
    How do I now 'print' the total SUM of all the numbers in the 'payment' column?

    Thanks.

  2. #2
    SitePoint Wizard silver trophy Karl's Avatar
    Join Date
    Jul 1999
    Location
    Derbyshire, UK
    Posts
    4,411
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    PHP Code:
        print "<br><br>Your Total Earnings Are: ";
        
    mysql_connect('$server''$username''$password') or die ("Database CONNECT Error"); 
        
    $set mysql_db_query($database"select SUM(payment) AS total from sales where refid = '$valid_user'") or die ("Database INSERT Error"); 
        }
        
    $row mysql_fetch_array$set );
        print 
    $row['total']; 
    Just a quick modificatino to your code (adding "AS total" after SUM(payment) ). hope this helps you.
    Karl Austin :: Profile :: KDA Web Services Ltd.
    Business Web Hosting :: Managed Dedicated Hosting
    Call 0800 542 9764 today and ask how we can help your business grow.

  3. #3
    SitePoint Enthusiast
    Join Date
    Nov 2001
    Location
    London, UK
    Posts
    62
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Great, i'll give it a go!



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
  •