I need a command that will add ALL the “money” together into one sum… So if this query returns 2 rows w/ money=10 and money=20, I need it to add money and money together, producing money=30… so that when I put the variable $totalmoney it will return the TOTAL of all the rows returned.
if this is a standard SQL query then just dump all the ‘money’ variables to a file and run a sum of on the file… you’ll have two commands running, but just run the sum command on the query of select money from table… but it doens’t look like you are using common SQL coding, unless that’s a fragment…
too bad i’m not a programmer… but i would just dump that query to a file and simply run a sum command.
if you aren’t a programmer, why are they making you do this? probably when i’m made to run query’s and fix lines of code… :rolleyes:
Well, this is a query within a PHP file. If I gave the actual query it would look even stranger because it’s using XMB Forum source code, although it’s not a forum. The sum of the total needs to be a variable because it’s going to be printed within HTML in the same file.
too bad i’m not a programmer… but i would just dump that query to a file and simply run a sum command.
? I have a giant PHP book in front of me, and the index says nothing under “sum”. Do you know the command?
if you aren’t a programmer, why are they making you do this? probably when i’m made to run query’s and fix lines of code… :rolleyes:
My “project” is just a database that prints out how many of each instrument and how much total $$ we quoted per instrument between dates x and y… it was 10X easier for me to do it in PHP rather than say Microsoft Access… I have it completely done, except for this last part. I wasn’t told to do it in PHP, just to do it.
I suppose now that my form will be finally finished I may get a raise… after all this project WAS done months ago until “boss man” decided to change it all around a week ago and make it 10X harder that it originally was… :finger2:
PHP book isn’t much help w/ SQL queries… and I’ve never seen a sum command before… I don’t study PHP & mysql, I just know what I’ve taught myself from coding XMB forums.
In SQL as long as you use the “group by” clause to make sets of tuples you have lots of aggregates you can use (sum, avg, max, etc.). Showtime did it right, notice that he has “instruments” as well as the obvoius “money” in the “select” clause, that is because you have to select the attribute you’re grouping by.