I need to sum the sum_total column. And echo result. See pic Month Total 100
<?php
//filter_weekly_activity_bydate.php
{
require 'db_connection2.php';
$stmt = $pdo->prepare( " SELECT *,
ifnull(left_count, 0) + ifnull(center_count, 0) + ifnull(right_count, 0) + ifnull(allother_count, 0) + ifnull(youthbalcony_count, 0) as sum_total
FROM weekly_activity_count
WHERE
month(date) = ?
AND
year(date) = ?
GROUP BY date desc
");
$stmt->execute([$_POST["month"],$_POST["year"]]);
$result = $stmt->fetchAll(PDO::FETCH_ASSOC);
//-----------------------------Table------------------------------------//
$output .= '
<table class="table table-bordered">
<tr>
<tr>
<th width="10%"><span>Left Section</span></th>
<th width="10%"><span>Center Section</span></th>
<th width="10%"><span>Right Section</span></th>
<th width="10%"><span>All Other Section</span></th>
<th width="10%"><span>Youth Balcony Section</span></th>
<th width="10%"><span>Sum Total</span></th>
<th width="10%"><span>Date</span></th>
</tr>
';
foreach($result as $row)
{
$output .= '
<tr>
<td>'. $row["left_count"] .'</td>
<td>'. $row["center_count"] .'</td>
<td>'. $row["right_count"] .'</td>
<td>'. $row["allother_count"] .'</td>
<td>'. $row["youthbalcony_count"] .'</td>
<td>'. $row["sum_total"] .'</td>
<td>'. $row["date"] .'</td>
</tr>
';
}
$output .= '</table>';
}
echo $output;
$pdo=null;
// By this way you can close connection in PDO.
?>