I try to write you some pseudocode.. Try to do something like this.
For the first, create new class Result for example.. There will be your rows from database in one array..
Class Result
{
private $rowName;
private $rowValue;
_construct Result()
{
$this->rowName="";
$this->rowValue="";
}
}
$query = "SELECT name FROM mybase WHERE name = '$name' ";
$mysqli = new mysqli();
$mysqli->connect('localhost', 'blabla', 'blabla', 'blabla');
$result = $mysqli->query($query);
$arrayResult = array();
while ($row = $result->fetch_assoc()) {
$arrayResult[] = $row['rowName'];
}
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<script type="text/javascript">
google.load("visualization", "1", {packages:["corechart"]});
google.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
['Name', 'Seen x times'],
<?php
foreach($arrayResult as $graphValue)
{
echo "['".$graphValue.getRowName()."'], ".$grapghValue.getRowValue()." ],"...
}
? >
]);
var options = {
title: 'My Daily Activities'
};
var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
</script>
</head>
<body>
<div id="chart_div" style="width: 900px; height: 500px;"></div>
</body>
</html>