-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.php
65 lines (48 loc) · 1.85 KB
/
index.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
<!DOCTYPE>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8">
<title>PHP Google Charts</title>
<script type="text/javascript" src="https://www.google.com/jsapi"></script>
<link href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.2.2/css/bootstrap-combined.min.css" rel="stylesheet">
</head>
<body>
<h1>PHP Google Charts</h1>
<?php
require_once('classes/classGRAPH.php');
require_once('classes/classDB.php');
$hostname = "<host>:<port>";
$username = "<username>";
$password = "<password>";
$dbname = "<database>";
$objDB = new mysql_db();
$objDB->sql_connect( $hostname, $username, $password, $dbname );
$ColumnChart = new Graph();
$ColumnChart->set_graphTitle ( "Hits Summary");
$ColumnChart->set_graphXLabel ( "Hour" );
$ColumnChart->set_graphYLabel ( "Total Hits" );
$ColumnChart->set_chartColumns ( array("Hour","Total Hits") );
$result = $objDB->query("select Hour(datetime) as hour, count(*) as hits from hits group by 1 order by 1 desc;");
$index = 0;
while($line = $objDB->fetch_row($result)) {
$rows [$index][0] = $line['hour'];
$rows [$index][1] = $line['hits'];
$index++;
}
$ColumnChart->set_chartRows( $rows );
$ColumnChart->set_chartGraph( "ColumnChart" );
$ColumnChart->get_chartGraph();
$objDB->sql_close();
// -------------------------------------------------------------------------------------------------------------------------------
$LineChart = new Graph();
$LineChart->set_graphTitle ( "Hits Summary" );
$LineChart->set_graphXLabel ( "Hour" );
$LineChart->set_graphYLabel ( "Total Hits" );
$LineChart->set_chartColumns ( array("Hour","Total Hits") );
$rows = array( 0 => array(0,5), 1 => array(1,10), 2 => array(2,15), 3 => array(3,20) );
$LineChart->set_chartRows( $rows );
$LineChart->set_chartGraph( "LineChart" );
$LineChart->get_chartGraph();
?>
</body>
</html>