Excuse me I got carried away with your code... <grin>
Check this out gives you some examples of what you could do...
The Sum fuction that the other guy posted is also a great way...
But if you want a little more control, especially if you are using a different database other than mysql this is a good technique...
$db = mysql_connect("xxxt", "xxx", "xxx");
mysql_select_db("orders",$db);
// declare the array before the query...
$all_orders_a = array();
$all_orders_b = array();
$all_orders_c = array();
$totresults=mysql_query("SELECT columna, columnb, columnc FROM Orders WHERE OrderDate BETWEEN '$year:$month:01' AND '$year:$month:31'");
$totresults=mysql_num_rows($totresults);
$query = "SELECT columna, columnb, columnc FROM Orders WHERE OrderDate BETWEEN '$year:$month:01' AND '$year:$month:31'";
$result = MYSQL_QUERY($query);
while ($row = mysql_fetch_array ($result) {
$columna = $row['columna'];
$columnb = $row['columnb'];
$columnc = $row['columnc'];
$all_orders_a[] = $columna;
$all_orders_b[] = $columnb;
$all_orders_c[] = $columnc;
$tr .= "<tr><td>$OrderDate</td><td>$OrderTotal</td></tr>";
}
$displaytable = "<table border=1><tr><td><B>Date</B></td><td><B>Order Total</B></td></tr>
$tr
<tr colspan=2 nowrap><td>$totresults orders found for month $month, $year</td></tr>
<tr colspan=2 nowrap><td>echo array_sum($all_orders_a) - array_sum($all_orders_b) - array_sum($all_orders_c)</td></tr>
";
// or
echo array_sum($all_orders_a);
echo array_sum($all_orders_b);
echo array_sum($all_orders_c);