title: Problems with retrieving mysql data into javascript in a specific format
body: <p>I'm trying to create a Highchart gantt chart using PHP and mysql. I have problem in retrieving data from the mysql database. 
  The format in the example given by Highchart Gantt to store the data is:</p>
  
  <pre><code> cars = [{
     model: 'Nissan Leaf',
     current: 0,
     deals: [{
       rentedTo: 'Lisa Star',
       from: today - 1 * day,
       to: today + 2 * day
     }, {
       rentedTo: 'Shane Long',
       from: today - 3 * day,
       to: today - 2 * day
     }, {
       rentedTo: 'Jack Coleman',
       from: today + 5 * day,
       to: today + 6 * day
     }]
    }}
  </code></pre>
  
  <p>This is my table for example:</p>
  
  <pre><code>kategori |sub categori | start_date | end_date
  -----------------------------------------------
  cat 1    | sub 1       | 2019-03-01 | 2019-03-04
  cat 2    | sub 2       | 2019-03-06 | 2019-03-10
  </code></pre>
  
  <p>I tried the following to retrieve the data from the mysql table to get the exact format like given in the example:</p>
  
  <p>The query:</p>
  
  <pre><code>   $query = "SELECT `kategori`, `sub_kategori`, `start_date`, `end_date`, FROM `table` ";
  </code></pre>
  
  <p>The function:</p>
  
  <pre><code>public function datatable_mini($query)
  {
      $stmt = $this-&gt;db-&gt;prepare($query);
      $stmt-&gt;execute();
  
      if($stmt-&gt;rowCount()&gt;0)
  
      {
          $y=$stmt-&gt;rowCount();
          $x=1;
  
          while($row=$stmt-&gt;fetch(PDO::FETCH_ASSOC))
          {
              $start_date = DateTime::createFromFormat('Y-m-d', $row['start_date']);
              $year = $start_date-&gt;format('Y');
              $month = $start_date-&gt;format('m');
              $day = $start_date-&gt;format('d');
          ?&gt;
  
              {
              &lt;br/&gt;
              &lt;span&gt;Kategori: '&lt;?php print($row['kategori']); ?&gt;',&lt;/span&gt;
              &lt;br/&gt;&lt;span&gt;current: 0,&lt;/span&gt;
              &lt;br/&gt;&lt;span&gt;deals: [{&lt;/span&gt;
              &lt;br/&gt;&lt;span&gt;SubKategori: '&lt;?php print($row['sub_kategori']); ?&gt;',&lt;/span&gt;
              &lt;br/&gt;&lt;span&gt;Mulai: Date.UTC(&lt;?php print($year); ?&gt;,&lt;?php print($month); ?&gt;,&lt;?php print($day); ?&gt;),&lt;/span&gt;
              &lt;br/&gt;&lt;span&gt;Selesai: Date.UTC(&lt;?php print(date('Y',strtotime($row['end_date']))); ?&gt;,&lt;?php print(date('m',strtotime($row['end_date']))); ?&gt;,&lt;?php print(date('d',strtotime($row['end_date']))); ?&gt;)&lt;/span&gt;
              &lt;br/&gt;
              }]
              &lt;br/&gt;}&lt;?php
  
              if($x&lt;$y){
                  echo ',';
              }
              $x=$x+1;
              ?&gt;
          &lt;?php
          }
      }
      else
      {
         echo "Nothing here...";
  
      }
  
  }
  </code></pre>
  
  <p>And this is in the javascript:</p>
  
  <pre><code>   cars = [&lt;?php echo $crud-&gt;datatable_mini($query); ?&gt;];
  </code></pre>
  
  <p>When I tried to echo the result, it gives the exact same format needed, like in the example:</p>
  
  <pre><code>{ 
  Kategori: 'cat 1', 
  current: 0, 
  deals: [{ 
      SubKategori: 'sub 1', 
      Mulai: Date.UTC(2019,03,01), 
      Selesai: Date.UTC(2019,03,04) 
      }] 
  }
  </code></pre>
  
  <p>etc..</p>
  
  <p>But no graph is shown.</p>
  
  <p>How can I retrieve the mysql data into the javascript with the format given in the example?</p>