Hi,
I’m using a function getMonthsInRange to get number of months in a date range. Code is as follows:
function getMonthsInRange($startDate, $endDate) {
$months = array();
while (strtotime($startDate) <= strtotime($endDate)) {
$months[] = array('year' => date('Y', strtotime($startDate)), 'month' => date('m', strtotime($startDate)), );
}
return $months;
}
foreach ($month_array as $m1) {
foreach ($m1 as $m2) {
$tds_row = mysql_query("SELECT *,SUM(comm_loop_amount * comm_loop_TDS/100) as tds FROM tbl_commission_loop
WHERE MONTH(comm_loop_date) = '".$m2."' AND comm_loop_agnt_id = '".$row['comm_loop_agnt_id']."'");
....
}
}
I copied this code from google but it is not giving month and year in different variables. Can anyone please tell me how to obtain both elements in the array?