Google timeline chart connect to Mysql PHP

Visto 642 veces
Saltar al primer mensaje no leído

Regi

no leída,
28 oct 2015, 12:55:3628/10/15
a Google Visualization API
Any you, please, could help me to fix this: I'm trying to connect a google timeline chart to my mysql database using PHP. I'm reading a loto on google but I realized I can't go further. Any one could give a hint on how this code below doesn't work? Any help will be appreciated. Also, I'm kind of basic in PHP.

Here is the code (not working) - also attached : 

<?php

    $con=mysql_connect("server","user","pass") or die("Failed to connect with database!!!!");

    mysql_select_db("databasename", $con);

    // Later on I'll need to change the way to connect in a more secured way).

    $sth = mysql_query("SELECT * FROM google tablename");

    

    

    $rows = array();

    $flag = true;

    $table = array();

    $table['cols'] = array(

                           array('type' => 'string', 'label' => 'PersonName'),

                           array('type' => 'date', 'label' => 'start'),

                           array('type' => 'date', 'label' => 'end'));

    

    //$rows = array();

    while($r = mysql_fetch_assoc($sth)) {

        $temp = array();

        $start = date("Y-m-d");

        $end = date("Y-m-d");

        

        $temp[] = array('v' => (string) $r['PersonName']);

        $temp[] = array('v' => (string) $r['start']);

        $temp[] = array('v' => (string) $r['end']);

        $rows[] = array('c' => $temp);}

    

    $table['rows'] = $rows;

    $jsonTable = json_encode($table);

    //echo $jsonTable;

    ?>







<html>

<head>



<script type="text/javascript" src="https://www.google.com/jsapi"></script>

<script type="text/javascript">

google.load("visualization", "1", {packages:["timeline"]});

google.setOnLoadCallback(drawChart);

<!--Load the Ajax API-->


function drawChart() {

    

    var container = document.getElementById('example3.1');

    var chart = new google.visualization.Timeline(container);

    var dataTable = new google.visualization.DataTable();

    var data = "" google.visualization.DataTable(<?php echo json_encode($table, JSON_NUMERIC_CHECK); ?>);

    

    var options = {

    title: 'Progress',

    is3D: true

        var options = {

        timeline: { colorByRowLabel: true }

        };

        

        chart.draw(dataTable, options);

    }

    

    </script>

    </head>

    

    <body>

    

    

    <div id="timeline" style="height: 180px;"></div>

    

    

    

    </body>

    </html>

googletimeline.php
Responder a todos
Responder al autor
Reenviar
0 mensajes nuevos