i m try to implement highcharts on my website but i dont know how i can get info from database on exactly away.
On my jquery i have this
xAxis: {
categories: [1,2,3,4,5,6,7,8,9,10]
},
this represent the days of the current month, like today is 10 so go 1 to 10
series: [{
name: 'acessos',
data: [1,0,0,0,0,0,7,0,0,4]
},
this represent the clicks by day
so my database have this structure
tabstats |tabstats.Stats_Id | tabstats.Stats_Type | tabstats.Stats_Clicks | tabstats.Stats_Date |
so them i have
Stats_Id = 1 / Stats_Type = 1 / Stats_Clicks = 10 / Stats_Date = 2012-05-01
Stats_Id = 2 / Stats_Type = 1 / Stats_Clicks = 5 / Stats_Date = 2012-05-02
etc for each day
so i m try to first get the current days of the month
and the clicks for each day.
Thanks for any help.
i figured how to output the days of the current month like this
for($i=1; $i <= date("d"); $i++) { $days[] = $i; }
echo json_encode($days); // ouput [1,2,3,4,5,6,7,8,9,10]
Now i just need to fix about the clicks
for($i=1;$i <= date("d"); $i++) {
$Sql = "SELECT COUNT(Stats_Clicks) AS Total FROM tabstats WHERE DAY(Stats_Date) = $i
AND MONTH(Stats_Date) = $month
AND YEAR(Stats_Date) = $year
";
$Query = mysql_query($Sql,$Conn) or die (mysql_error($Conn));
$Rs = mysql_fetch_array($Query);
$clicks[] = $Rs['Total'];
}
echo json_encode($clicks);
but here i got a problem, the json output returns this
["1","1","0","0","0","0","0","0","0","0","0"]
but i need without quotes, i tried using a simple vector but dint works for me.
I dont know if my code is the best solution or correctly but this is the only away i m going to the result i need.
thanks.
Solution
fixed.