Reputation: 2594
i am using graph from http://www.chartjs.org this is an JavaScript ,but I want to display the data on the chart from my database value. can any one guide me how to do it
Upvotes: 0
Views: 219
Reputation: 3427
Use this:
$query = "select * from table";
$res = mysql_query($query);
$row = mysql_fetch_assoc($res);
Define the above code before Graph content loads. And then use it in JavaScript.
<script>
var value1 = <?php echo $row['field1']; ?>
var value2 = <?php echo $row['field2']; ?>
</script>
You can use like this. Tell me do have any further query.
Upvotes: 2