<?php


header('Content-Type: application/json');

include_once('../config/conn/db-connection.php');



$q = $db->query("SELECT COUNT(monthly_income) as cnt, SUM(monthly_income) as income,DATE_FORMAT(date_created, '%M') as month_s FROM tbl_beneficiaries GROUP BY DATE_FORMAT(date_created, '%M')")->fetchAll();
// $q = $db->query("SELECT count(*) as cnt, month(monthly_income) as income FROM tbl_beneficiaries group by month(monthly_income)")->fetchAll();
              // SELECT count(*) as cnt, round(monthly_income/12,2) as income FROM tbl_beneficiaries group by monthly_income

      $data = array();
      foreach ($q as $row) {
        $data[] = $row;
      }

    echo json_encode($data);
?>