On Mon, Jan 28, 2008 at 3:02 PM, O'Brien, Kevin wrote:
On Jan 23, 2008 12:02 PM, O'Brien, Kevin
Hi guys,
I am very new to using PHP and am working on my first site so I'm
sorry
if this question is trivial. I have created a table that returns the
first row from a table. It has the date in the first column and then
five more columns with numbers. I would like to get the sum of those
five columns. Any help would be greatly appreciated!
I'm pasting my code below.
Thank you.
Kevin
All my code. Generated with Dreamweaver...
<snip by moderator>
--------------------------------
hi,
you can try to change this query
$query_Edrive = "SELECT servers.`Date`, servers.exchangemb1e,
servers.exchangemb2e, servers.exchangemb3e, servers.exchangemb4e,
servers.exchangemb5e FROM servers ORDER BY servers.`Date` DESC";
to
$query_Edrive = "SELECT servers.`Date`, servers.exchangemb1e +
servers.exchangemb2e + servers.exchangemb3e + servers.exchangemb4e +
servers.exchangemb5e FROM servers ORDER BY servers.`Date` DESC";
i think that solves yout problem.
sorry about my english, i'm newbie.
--
Atenciosamente.
Gustavo Coutinho
-----------------------
Hi Gustavo,
Unfortunately this did not work for me. What I would like to do is keep
the table and the data that I have already and add a new cell or even a
text box with the total from the table.
Thanks for your help,
Kevin
--------------------------
Do you wanna get the total from the table ? or from row ?
if you wanna get the total from the table, i dont know do that in sql code.
I think that you should do with php code.
for example : in your sql you can add more a colunm with the sun of the
others
$query_Edrive = "SELECT servers.`Date`, servers.exchangemb1e,
servers.exchangemb2e, servers.exchangemb3e, servers.exchangemb4e,
servers.exchangemb5e, servers.exchangemb1e + servers.exchangemb2e +
servers.exchangemb3e + servers.exchangemb4e +
servers.exchangemb5e as sun FROM servers ORDER BY servers.`Date` DESC";
and to try that:
$query = mysql_query($query_Edrive);
while($row = mysql_fetch_array($query) {
$total row += $row['sun'];
}
i hope to be help you.
--
Atenciosamente.
Gustavo Coutinho