i have installed highcharts on web site, have problem. mysql returns data in value:
['26.03.2013', 1], ['26.03.2013', 1], ['26.03.2013', 1], ['26.03.2013', 1], ['26.03.2013', 1], ['11.03.2013', 1], ['21.03.2013', 1], ['22.03.2013', 1]
and included in highcharts that:
$('#chart').highcharts({ chart: { type: 'line' }, title: { text: 'statistika prenosov' }, xaxis: { title: { text:'datum' } }, yaxis:{ title: { text:'prenosi' }, plotlines: [{ value: 0, width: 1, color: '#808080' }] }, series: [{ name: 'prenosi', data: [['26.03.2013', 1], ['26.03.2013', 1], ['26.03.2013', 1], ['26.03.2013', 1], ['26.03.2013', 1], ['11.03.2013', 1], ['21.03.2013', 1], ['22.03.2013', 1]] }] }); });
but want, if there 3 dates 26.3.2013, don't show them each alone, put them together, result should 3, not 3x1.
here is, how fetch results php:
$query=mysql_query("select * downloads prjid='".$_get['id']."' order date asc"); $num=mysql_num_rows($query); $res=''; $i=0; while($row=mysql_fetch_array($query)){ $i++; $date=date("d.m.y", strtotime($row['date'])); $numb=1; if($i!=$num){ $res.="['".$date."', ".$numb."], "; } else{ $res.="['".$date."', ".$numb."]"; } }
the simplest thing modify sql sum you. if trying display count of each date, change query to:
select date,count(*) num downloads prjid='".$_get['id']."' group date order date asc"
Comments
Post a Comment