<?php
$connect = mysqli_connect("localhost", "root", "123456", "testing");
$query="select uniqueid, managerid from employees";
/*
# Collect the results
while($obj = mysql_fetch_object($query)) {
    $arr[] = $obj;
}

# JSON-encode the response
$json_response = json_encode($arr);

// # Return the response
echo $json_response;
*/
$result = mysqli_query($connect, $query);  
?>
<html>
<head>
<script type='text/javascript' src='https://www.google.com/jsapi'></script>
<script type='text/javascript' src='jquery-1.6.2.min.js'></script>
<script type='text/javascript'>
google.load('visualization', '1', { packages: ['orgchart'] });
google.setOnLoadCallback(drawChart);
function drawChart()  
           {  
                var data = google.visualization.arrayToDataTable([  
                          ['UniqueId', 'ManagerId'],  
                         
<?php  
                          while($row = mysqli_fetch_array($result))  
                          {  
                              
  echo "['".$row[1]."', ".$row[0]."],"; 
  
                          }  
                          ?>   
                     ]);  
            var data = new google.visualization.DataTable(jsonData); 
        // For each orgchart box, provide the name, manager, and tooltip to 
show.
        data.addRows([
           
            var chart = new 
google.visualization.OrgChart(document.getElementById('chart_div'));
             chart.draw(data, { allowHtml: true });
          }
</script>

</head>
<body>
<div id="chart_div"></div>
</body>
</html>
------------------------------------------------
database table name employees
UniqueId                  ManagerId             Name
1                                    0                       ABC
2                                     1                     DEF
3                                    1                       GHI
4                                     2                       JKL
5                                     2                       MNO

-- 
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 https://groups.google.com/group/google-visualization-api.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/google-visualization-api/447d6317-bbcd-4bf4-8d9f-e5053ecb9bb6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to