dapcigar Posted July 4, 2014 Share Posted July 4, 2014 Hello all, Am trying to calculate some data and display the result of the current month in a chart form. i just don't know how to get the current month. this is not working.. <?php include('mysql_connect.php'); $date = 'MONTH(CURRENT_DATE())'; $status = 'paid'; //mysql_select_db("hyprops", $con); $query = mysql_query("SELECT sum(amount) 'amount', department FROM requisition WHERE status = '$status' AND date='$date' "); $category = array(); $category['name'] = 'department'; //$series1 = array(); //$series1['name'] = 'actual'; $series2 = array(); $series2['name'] = 'amount'; //$series3 = array(); //$series3['name'] = 'Highcharts'; while($r = mysql_fetch_array($query)) { $category['data'][] = $r['department']; // $series1['data'][] = $r['actual']; $series2['data'][] = $r['amount']; // $series3['data'][] = $r['highcharts']; } $result = array(); array_push($result,$category); //array_push($result,$series1); array_push($result,$series2); //array_push($result,$series3); print json_encode($result, JSON_NUMERIC_CHECK); mysql_close($con); ?> Please how can i solve this issue? Thanks in advance Link to comment https://forums.phpfreaks.com/topic/289431-getting-current-month-and-displaying-result-on-chart/ Share on other sites More sharing options...
dapcigar Posted July 4, 2014 Author Share Posted July 4, 2014 Nevermind, i fixed it. incase someone elese needs the solution MONTH(date) = MONTH(CURRENT_DATE) Link to comment https://forums.phpfreaks.com/topic/289431-getting-current-month-and-displaying-result-on-chart/#findComment-1483798 Share on other sites More sharing options...
mac_gyver Posted July 4, 2014 Share Posted July 4, 2014 your solution will get data from every matching month, ..., 2012-07, 2013-07, 2014-07. if you really only want the current month, you need to match both the current year and the current month. Link to comment https://forums.phpfreaks.com/topic/289431-getting-current-month-and-displaying-result-on-chart/#findComment-1483829 Share on other sites More sharing options...
dapcigar Posted July 9, 2014 Author Share Posted July 9, 2014 oh really? so how do i do that? thanks in advance Link to comment https://forums.phpfreaks.com/topic/289431-getting-current-month-and-displaying-result-on-chart/#findComment-1484386 Share on other sites More sharing options...
maxxd Posted July 9, 2014 Share Posted July 9, 2014 "WHERE MONTH(date) = MONTH(CURRENT_DATE) AND YEAR(date) = YEAR(CURRENT_DATE)" should do it. Link to comment https://forums.phpfreaks.com/topic/289431-getting-current-month-and-displaying-result-on-chart/#findComment-1484409 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.