I have a php foreach loop which I would like to use to create 5 charts based on the data that i feed into the script. The problem that I cant figure out is that at the moment my chart is visible only at the last loop and is not visible on the first, second, third.
I tried to do something like var chart<?=$row['id'];?>=...
to no avail. How can I get my charts to appear with the correct data in the foreach loop?
<? foreach($articles as $row):?>
<div id='chart-<?=$row['id'];?>' style='width: 1110px; height: 250px;'></div>
<script>
var chart1 = new Charts.LineChart('chart-<?=$row['id'];?>', {
dot_color: "#855541",
area_color: "#855541",
line_color: "#855541",
line_width: 1,
show_grid: false,
label_max: false,
label_min: false
});
chart1.add_line({
data: [<?=$row['chart'];?>]
});
chart1.draw();
</script>
<?endforeach;?>
foreach
loop? Please edit your question to show how you are currently doing it. – Bart Jan 7 at 8:53<?=
should be replaced with<?php echo
? – I Can Has Cheezburger Jan 7 at 8:56