Forum Moderators: coopster
Here's my MySQL query:
$query = "SELECT DATE_FORMAT(date_transac_f, '%m/%d/%Y') AS Fdate_transac_f, name, currency, gross, fee, net, from_email, transac_id, item_title, subscription_number, receipt_id, SUM(gross) AS gross_total, SUM(fee) AS fee_total, SUM(net) AS net_total FROM tablename WHERE currency = '$currency' GROUP BY currency ORDER BY date_transac_f"; Here's how I print all the returned rows:
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr class=\"textbox_grey\"><td class=\"t13\">".$Fdate_transac_f."</td><td class=\"t13\">".$name."</td><td class=\"t13\">".$currency."</td><td align=\"right\" class=\"t13_red\">".$gross."</td><td align=\"right\"class=\"t13\">".$fee."</td><td align=\"right\"class=\"t13_red\">".$net."</td><td class=\"t13\">".$from_email."</td><td class=\"t13\">".$transac_id."</td><td class=\"t13\">".$item_title."</td><td class=\"t13\">".$subscription_number."</td><td class=\"t13\">".$receipt_id."</td></tr>\n";
}
What would be the syntax to print at the bottom of the table, the sums of the columns gross, fee and net?
while ($row = mysql_fetch_array($result))
{
extract($row);
echo "<tr class=\"textbox_grey\"><td class=\"t13\">".$Fdate_transac_f."</td><td class=\"t13\">".$name."</td><td class=\"t13\">".$currency."</td><td align=\"right\" class=\"t13_red\">".$gross."</td><td align=\"right\"class=\"t13\">".$fee."</td><td align=\"right\"class=\"t13_red\">".$net."</td><td class=\"t13\">".$from_email."</td><td class=\"t13\">".$transac_id."</td><td class=\"t13\">".$item_title."</td><td class=\"t13\">".$subscription_number."</td><td class=\"t13\">".$receipt_id."</td></tr>\n";
$btm_gross = $btm_gross + $gross;
$btm_fee = $btm_fee + $fee;
$btm_net = $btm_net+ $net;
}
echo "<tr class=\"textbox_grey\"><td class=\"t13\"> </td><td class=\"t13\"> </td><td class=\"t13\"> </td><td align=\"right\" class=\"t13_red\">".$btm_gross."</td><td align=\"right\"class=\"t13\">".$btm_fee."</td><td align=\"right\"class=\"t13_red\">".$btm_net."</td><td class=\"t13\"> </td><td class=\"t13\"> </td><td class=\"t13\"> </td><td class=\"t13\"> </td><td class=\"t13\"> </td></tr>\n";
Habtom