-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsample.php
67 lines (45 loc) · 1.48 KB
/
sample.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
<?php
$opened='';
$closed1='';
$connection = mysqli_connect('localhost', 'root', '', 'agris');
$result = mysqli_query($connection, "SELECT * FROM farminfo");
//if($result){
// echo "CONNECTED";
//}
?>
<!doctype html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
<script type="text/javascript">
google.charts.load('current', {'packages':['bar']});
google.charts.setOnLoadCallback(drawChart);
function drawChart() {
var data = google.visualization.arrayToDataTable([
[ 'crabtype', 'weight'],
<?php
if(mysqli_num_rows($result)> 0){
while($row = mysqli_fetch_array($result)){
echo "[ '".$row['crabtype']."', ['".$row['weight']."']],";
}
}
?>
]);
var options = {
chart: {
title: 'Mud crab sex and type',
width: 5000,
height: 500
}
};
var chart = new google.charts.Bar(document.getElementById('columnchart_material'));
chart.draw(data, google.charts.Bar.convertOptions(options));
}
</script>
</head>
<body>
<div id="columnchart_material"></div>
</body>
</html>