Column Totals

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



I am trying to get the total sales revenue for each day of the month, and
having no luck at all.

The following query seems to return an empty string, which should only give
me the total for the entire column anyway.
$query = "SELECT SUM(Revenue) FROM Sales WHERE Date='$Date'";


I also tried, among many, many things, to use a for loop to get the sum for
each date, month to date, such as:

$Today = date("d");

for ($i = 1; $i < $Today; $i++) {

   $query = "SELECT SUM(Revenue) FROM Sales WHERE Date='$i'";

}

In case it helps, sample table data might look like this:

OrderNo        OrderDate        Revenue
1111               1                      79.95
1112               1                      39.95
1113               3                      89.95

and I am trying to produce something that would show:

<TABLE>
    <TR>
        <TD>Date</TD><TD>Revenue</TD>
    </TR>
    <TR>
        <TD>1</TD><TD>119.90</TD>
    </TR>
    <TR>
        <TD>2</TD><TD>0.00</TD>
    </TR>
    <TR>
        <TD>3</TD><TD>89.95</TD>
    </TR>
</TABLE>


PLEASE HELP.   PLEASE!!!!!!  And many, many thanks in advance!!!!

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux