Thanks for the help asgallant. After editing my code it gives an error of 
Invalid data at row #0: start(Sat Dec 28 2013 00:00:00 GMT+1000 (E. 
Australia Standard Time)) > end(Sun Aug 11 2013 00:00:00 GMT+1000 (E. 
Australia Standard Time)).×

Its including time with the data too 

And y is this happening. Could you plz explain about it on how to generate 
the chart plz

My re-edited codes 

php
<?php
$con=mysqli_connect("localhost","root","","test");
if (mysqli_connect_errno())
  {
  echo "Failed to connect to MySQL: " . mysqli_connect_error();
  }
  $sql = mysqli_query($con,"SELECT consultant, client, role, likelyhood, 
IFNULL(startdate, '0000-00-00') AS startdate, IFNULL(enddate, '0000-00-00') 
AS enddate, state, comments_ FROM fabrik");
  if (!$sql) {
  die("Error running $sql: " . mysql_error());
  }
  $results = array(
    'cols' => array (
        array('label' => 'consultant', 'type' => 'string'),
       // array('label' => 'client', 'type' => 'varchar'),
        array('label' => 'state', 'type' => 'string'),
        //array('label' => 'role', 'type' => 'string'),
        //array('label' => 'likelyhood', 'type' => 'varchar'),
        array('label' => 'enddate', 'type' => 'datetime'),
        array('label' => 'startdate', 'type' => 'datetime'),
            
        //array('label' => 'comments_', 'type' => 'text')
    ),
    'rows' => array()
);
while($row = mysqli_fetch_assoc($sql)) {
    // date assumes "yyyy-MM-dd" format
  $start_year = 0;
$start_month = 0;
$start_day = 0;
$end_year = 0;
$end_month = 0;
$end_day = 0;

$startdateArr = explode('-', $row['startdate']);

if(count($startdateArr) == 3){
    $start_year = (int) $startdateArr[0];
    $start_month = (int) $startdateArr[1]-1;
    $start_day = (int) $startdateArr[2];
}

$enddateArr = explode('-', $row['enddate']);

if(count($enddateArr) == 3){
    $end_year = (int) $enddateArr[0];
    $end_month = (int) $enddateArr[1] - 1;
    $end_day = (int) $enddateArr[2];
}

$results['rows'][] = array('c' => array(
    
    //array('v' => $row['role']),
    array('v' => $row['consultant']),
    array('v' => $row['state']),
   // array('v' => $row['client']),
    
    //array('v' => $row['likelyhood']),
    array('v' => "Date($end_year, $end_month, $end_day)"),
    array('v' => "Date($start_year, $start_month, $start_day)"),
    
    
   // array('v' => $row['comments_'])
));
   // $startdateArr = explode('-', $row['startdate']);
   // $year = (int) $startdateArr[0];
    //$month = (int) $startdateArr[1] - 1; // subtract 1 to make month 
compatible with javascript months
   // $day = (int) $startdateArr[2];

    //$enddateArr = explode('-', $row['enddate']);
    //$year = (int) $enddateArr[0];
    //$month = (int) $enddateArr[1] - 1; // subtract 1 to make month 
compatible with javascript months
   // $day = (int) $enddateArr[2];

    // time assumes "hh:mm:ss" format
    //$timeArr = explode(':', $row['Time']);
   // $hour = (int) $timeArr[0];
   // $minute = (int) $timeArr[1];
   // $second = (int) $timeArr[2];

   // $results['rows'][] = array('c' => array(
   //     array('v' => $row['consultant']),
   //     array('v' => $row['client']),
   //     array('v' => $row['role']),
   //     array('v' => $row['likelyhood']),
   //     array('v' => "startdate($year, $month, $day)"),
   //     array('v' => "enddate($year, $month, $day)"),
   //     array('v' => $row['state']),
   //     array('v' => $row['comments_'])
   // ));
}
$json = json_encode($results, JSON_NUMERIC_CHECK);
echo $json;
?>

html

<html>
  <head>
    <!--Load the AJAX API-->
    <script type="text/javascript" 
src="https://www.google.com/jsapi";></script>
    <script type="text/javascript" 
src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>
    <script type="text/javascript" 
src="https://www.google.com/jsapi?autoload={'modules':[{'name':'visualization',
       'version':'1','packages':['timeline']}]}"></script>
   <script type="text/javascript">
  $(function() {
    // Load the Visualization API and the piechart package.
    //google.load('visualization', '1', {packages: ['table']});
    google.load("visualization", "1", {packages:["timeline"]});

    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);

     }
     );
   function drawChart() {
      $.ajax({
        url: "http://localhost:8080/index1.php";,
        dataType:"json",
        async: false ,
        success: function(data) {
         jsonData = data;
          // Create our data table out of JSON data loaded from server.
         var data = new google.visualization.DataTable(jsonData);
          //visualization = new 
google.visualization.Table(document.getElementById('table'));
         //  visualization.draw(data, {width: 500, height: 240});

          // Instantiate and draw our chart, passing in some options.
          var chart = new 
google.visualization.Timeline(document.getElementById('chart_div'));
          chart.draw(data, {width: 500, height: 240});
        }
      })  
    };
   
  
</script>
  </head>

  <body>
    <div id="table"></div>
    <div id="chart_div" ></div>
  </body>
</html>


-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to