01.
<?php
02.
03.
$host
=
"xxxxxxxxxxxxx"
;
04.
$user
=
"xxxxxxxxxxxxx"
;
05.
$pwd
=
"xxxxxxxxxxxxx"
;
06.
$db
=
"xxxxxxxxxxxxx"
;
07.
global
$link
;
08.
$link
= mysql_connect(
$host
,
$user
,
$pwd
)
or
die
(
"Could not connect to MySQL"
);
09.
mysql_query(
"SET NAMES UTF8"
,
$link
);
10.
mysql_select_db(
$db
,
$link
)
or
die
(
"Could not select $db database"
);
11.
12.
13.
14.
$sql
=
"SELECT unix_timestamp(service.visitdate)*1000 AS date, service.cvno AS val FROM service GROUP BY date"
;
15.
16.
$result
= mysql_query(
$sql
);
17.
18.
?>
19.
<!DOCTYPE HTML>
20.
<html>
21.
<head>
22.
<meta http-equiv=
"Content-Type"
content=
"text/html; charset=utf-8"
>
23.
<title>Highstock Example</title>
24.
28.
<script type=
"text/javascript"
>
29.
$(
function
() {
30.
31.
$(
'#container'
).highcharts(
'StockChart'
, {
32.
33.
34.
rangeSelector : {
35.
selected : 1
36.
},
37.
38.
title : {
39.
text :
'จำนวนผู้รับบริการ'
40.
},
41.
yAxis: {
42.
min: 0,
43.
},
44.
45.
series : [{
46.
name :
'จำนวนผู้รับบริการ(ครั้ง)'
,
47.
data : [<?php
while
(
$row
=mysql_fetch_array(
$result
)) {
48.
$val
=
$row
[val];
49.
$datestamp
=
$row
[
date
];
50.
$sss
=
"["
.
$datestamp
.
","
.
$val
.
"],"
;
51.
echo
$sss
;
52.
} ?>],
53.
tooltip: {
54.
valueDecimals: 2
55.
}
56.
}]
57.
});
58.
});
59.
</script>
60.
</head>
61.
<body>
62.
<div id=
"container"
style=
"height: 500px; min-width: 500px"
></div>
63.
</body>
64.
</html>