|
 |
|
ใช้ php ดึงข้อมูลจาก sql แล้วนำมาใช้กับจาวาสคริปแล้วนำข้อมูลมาแสดงเป็นกราฟแต่ไม่มีคอมม่าที่ตัวเลขทำไงดีครับ |
|
 |
|
|
 |
 |
|
ใช้php ดึงข้อมูลจาก sql แล้วนำมาใช้กับจาวาสคริปแล้วนำข้อมูลมาแสดงเป็นกราฟแต่ไม่มีคอมม่าที่ตัวเลขทำไงดีครับ
Code (PHP)
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=tis-620">
<title>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("httcoopc_coop");
@mysql_query("SET character_set_client = tis620"); // set ภาษาให้กับเว็บไซต์
@mysql_query("SET character_set_connection = tis620");
@mysql_query("SET character_set_database = tis620");
@mysql_query("SET character_set_results = tis620");
@mysql_query("SET character_set_server = tis620");
$strSQL = "SELECT * FROM reportcoop where id='$id' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
$i = 0;
while($objResult = mysql_fetch_array($objQuery)){?>
<?=$objResult['detail'];?>ย้อนหลัง4 <??>
</title>
<div align='center'><?=$objResult['detail'];?>ย้อนหลัง4</div> <?}?>
<script type="text/javascript" src="jquery.min.js"></script>
<?
$objConnect = mysql_connect("localhost","root","root") or die("Error Connect to Database");
$objDB = mysql_select_db("httcoopc_coop");
$strSQL = "SELECT * FROM reportcoop where id='$id' ";
$objQuery = mysql_query($strSQL) or die ("Error Query [".$strSQL."]");
while($objResult = mysql_fetch_array($objQuery))
{
$xx=$objResult["2555"];
?>
<script type="text/javascript">
$(function () {
var chart;
var str=new String("<?=$objResult["detail"];?>");
var y1=<?=$xx;?>;
var y2=<?=$objResult["2554"];?>;
var y3=<?=$objResult["2553"];?>;
var y4=<?=$objResult["2552"];?>;
$(document).ready(function() {
var colors = Highcharts.getOptions().colors,
categories = ['31 มีนาคม 2555', '31มีนาคม 2554', '31 มีนาคม 2553', '31 มีนาคม 2552'],
name = 'Browser brands',
data = [{
y: y1,
color: colors[0],
}, {
y: y2,
color: colors[1],
}, {
y: y3,
color: colors[2],
}, {
y: y4,
color: colors[3],
} ];
function setChart(name, categories, data, color) {
chart.xAxis[0].setCategories(categories);
chart.series[0].remove();
chart.addSeries({
name: name,
data: data,
color: color || 'white'
});
}
chart = new Highcharts.Chart({
chart: {
renderTo: 'container',
type: 'column'
},
title: {
text: ''
},
subtitle: {
text: str
},
xAxis: {
categories: categories
},
yAxis: {
title: {
text: str
}
},
plotOptions: {
column: {
cursor: 'pointer',
point: {
events: {
click: function() {
var drilldown = this.drilldown;
if (drilldown) { // drill down
setChart(drilldown.name, drilldown.categories, drilldown.data, drilldown.color);
} else { // restore
setChart(name, categories, data);
}
}
}
},
dataLabels: {
enabled: true,
color: colors[0],
style: {
fontWeight: 'bold'
},
formatter: function() {
return this.y +'คน';
}
}
}
},
tooltip: {
formatter: function() {
var point = this.point,
s = this.x +':<b>'+ this.y +'(คน)</b><br/>';
if (point.drilldown) {
s += 'Click to view '+ point.category +' versions';
} else {
s += '';
}
return s;
}
},
series: [{
name: name,
data: data,
color: 'white'
}],
exporting: {
enabled: false
}
});
});
});
</script><?
}
?>
</head>
<body>
<script src="js/highcharts.js"></script>
<script src="js/modules/exporting.js"></script>
<div id="container" style="min-width: 400px; height: 400px; margin: 0 auto"></div>
</body>
</html>
ขอบคุณครับ
Tag : MySQL, JavaScript, Windows

|
|
 |
 |
 |
 |
Date :
2012-09-18 08:44:39 |
By :
visau |
View :
2333 |
Reply :
1 |
|
 |
 |
 |
 |
|
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<?php
$number = 1234.56;
// english notation (default)
$english_format_number = number_format($number);
// 1,235
// French notation
$nombre_format_francais = number_format($number, 2, ',', ' ');
// 1 234,56
$number = 1234.5678;
// english notation without thousands separator
$english_format_number = number_format($number, 2, '.', '');
// 1234.57
?>
|
 |
 |
 |
 |
Date :
2012-09-18 11:49:19 |
By :
mr.win |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|