title: create Chart using Chartjs and PHP
body: <p>I need to create a chart using chartJS which gets the data from mysql, below is a sample output from mysql table:</p>
  
  <pre><code>+----+------------+----------+-----------------+----------
  | ID | DATE       | Time     | Create | Delete | Product |
  +----+------------+----------+-----------------+---------+
  |  1 | 03/12/2017 | 09:00:00 |     28 |   1264 |      59 | 
  </code></pre>
  
  <p>ive managed to put the data in JSON format, using the toturial <a href="https://stackoverflow.com/questions/12994282/php-mysql-google-chart-json-complete-example">here</a>, below is the PHP file:</p>
  
  <p><strong>get.php</strong></p>
  
  <pre><code>&lt;?php
  
  $DB_NAME = 'testDB';
  $DB_HOST = 'localhost';
  $db_port = '3306';
  $DB_USER = 'test';
  $DB_PASS = 'mysql';
  $mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASS, $DB_NAME);
  
    if (mysqli_connect_errno()) {
      printf("Connect failed: %s\n", mysqli_connect_error());
      exit();
    }
  
    $result = $mysqli-&gt;query('Select * from (SELECT * FROM Stats ORDER BY id DESC LIMIT 48)t ORDER BY id ASC');
    $rows = array();
    $table = array();
    $table['cols'] = array(
      array('label' =&gt; 'Time', 'type' =&gt; 'string'),
     array('label' =&gt; 'ProductCreate', 'type' =&gt; 'number'),
     array('label' =&gt; 'ProductDelete', 'type' =&gt; 'number'),
     array('label' =&gt; 'ProductRenew', 'type' =&gt; 'number')
  
  );
      foreach($result as $r) {
  
        $temp = array();
  
        $temp[] = array('v' =&gt; (string) $r['Time']); 
        $temp[] = array('v' =&gt; (int) $r['Create']);
        $temp[] = array('v' =&gt; (int) $r['Delete']);
        $temp[] = array('v' =&gt; (int) $r['Renew']);
  
        $rows[] = array('c' =&gt; $temp);
      }
  
  $table['rows'] = $rows;
  
  // convert data into JSON format
  $SubsStats = json_encode($table);
  echo $SubsStats;
  
  
  ?&gt;
  </code></pre>
  
  <p>My question now is how can I include the PHP output into my HTML file and draw the chart using ChartJS?</p>
  
  <p>Thanks,
  Ali</p>