0
Well, it’s as follows I have the table invoices, with a certain column designated by "earnings".
Each record, corresponds to a day, what I intend to do is a php script, which adds me all the "gains" of all the records, ie every day.
How can I do that?
Thank you
you can do by SQL...
SUM(ganhos) as ganhos
– Marllon Nasser
I intend to do by PHP, to show me in the Adm panel.
– Gonçalo
In the link above you have examples of use of the general SUM, for certain condition and for grouping. If it is still not what you are looking for, you can [Dit] the question and add more details of your specific case to consider alternatives. For example, as he commented to do in PHP, it would be good to put the code snippet that shows the data, because if you have paging etc, changes everything.
– Bacco
Add the columns by SQL:
SELECT SUM(ganhos) FROM tabela;
and in PHP:$resultset = mysql_query('SELECT SUM(ganhos) as ganhos FROM tabela'); 
$linha= mysql_fetch_assoc($resultset); 
$soma = $linha['ganhos'];
– Marllon Nasser
And even in PHP if it’s not going to display all the data on the screen, SUM is still the most practical (it’s a select like any other, you can take PHP and show it on the screen) - SUM is just not an advantage when the entire listing will be displayed, then you just do a
$total = $total + $row['valor']
inside the loop– Bacco
I got it, thank you very much Marllon, that’s how I got it!
– Gonçalo
Thank you all for your help!
– Gonçalo