Home forums Chart Support How can I use PHP MySQL Dynamic data Reply To: How can I use PHP MySQL Dynamic data


Hi Sunil, I have tried a lot of things but my graph is still not rendering. I don’t know what could be the problem. jquery not running? or any other issue that I am not aware of.

Here is my code:

My data.php file:

<?php ob_start(); ?>

include ‘core/init.php’;
include ‘includes/overall/overallheader.php’;


$sql=(“SELECT * FROM users”); {

$result=mysql_query($sql) or die(“SQL Error 1: ” . mysql_error());
// get data and store in a json array
$points[] = array(
‘Q1’ => $rows[‘question_1’],
‘Q2’ => $rows[‘question_2’],
‘Q3’ => $rows[‘question_3’]
echo json_encode($points, JSON_NUMERIC_CHECK);
include ‘includes/overall/overallfooter.php’;

which returns: [{“Q1″:2,”Q2″:3,”Q3″:2}]

My HTML file

<!DOCTYPE html>
<html xmlns=”http://www.w3.org/1999/xhtml&#8221; ><head>
<script src=”/jquery-1.10.2.js”></script>
<script type=”text/javascript” src=”js/canvasjs.min.js”></script>
<script type=”text/javascript”>
$(document).ready(function () {
$.getJSON(“data.php”, function (result) {
var chart = new CanvasJS.Chart(“chartContainer”, {
data: [ { dataPoints: result } ]
<div id=”chartContainer” style=”width: 800px; height: 380px;”></div>

This does not render the graph. I am using Safari and develop in localhost through MAMP environment.

Thanks in advance for your reply.