On Tue, Jan 29, 2008 at 3:39 PM, O'Brien, Kevin <[EMAIL PROTECTED]> wrote:
> 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
>
> Hi Gustavo,
>
> With your direction I have got it working now. This is the code I
> used:
>
> $GetTotal = $row_dailySum['Sum(servers.exchangemb1e +
> servers.exchangemb2e + servers.exchangemb3e + servers.exchangemb4e +
> servers.exchangemb5e)'];
>
> echo number_format ($GetTotal)
>
> Thank you very much. I would not have gotten it without your help.
>
> Kevin
>
-----------------
Kevin,
you're wellcome.
>
> .
>
> <http://geo.yahoo.com/serv?s=97359714/grpId=303031/grpspId=1705005703/ms
> gId=21841/stime=1201577710/nc1=3848641/nc2=4025373/nc3=5045819>
>
>
> [Non-text portions of this message have been removed]
>
>
>
--
Atenciosamente.
Gustavo Coutinho
[Non-text portions of this message have been removed]