I am trying to add the sales of the month and showing it on the table. Everything is working fine but a warning message is showing Undefined offset: 9.
Kindly check the code what I am doing:
$thisyear = $db->query("SELECT total_Price,order_date FROM orderTable WHERE YEAR(order_date) = '{$thisyear}'");
$current = array();
$currentTotal = 0;
while($x = mysqli_fetch_assoc($thisyear)){
$month = date("m-d-Y",strtotime($x['order_date']));
//The Below line showing Error
$current[(int)$month] += $x['grand_total']; // This line showing Error
$currentTotal += $x['total_Price'];
}
With this code, I am getting the correct result. It is adding the monthly sales and showing it on the table but a warning message is also showing.
Kindly suggest what I am doing wrong.