データベースに接続し、javascript 棒グラフを作成したときに、javascript を使用してデータベースから値を取得したいと考えています。誰かがそれを調べて助けてくれるなら、以下は私のコードです。
<?php
ini_set('display_errors',1);
error_reporting(E_ALL);
$link = mysql_connect('localhost', 'root', 'root');
mysql_select_db('sarc', $link);
$result = mysql_query('SELECT 73');
$val = mysql_fetch_row($result);
$val = $val[0];
?>
<link rel="stylesheet" type="text/css" href="progressbar.css" />
<script type="text/javascript" src="progressbar.js"></script>
<style type="text/css">
.my_progress_bar {
border-width: 0px;
}
</style>
<div id="my_progress_bar_1"></div>
<script type="text/javascript">
var currentValue = [<?php echo $val; ?>];
var myProgressBar = null
var timerId = null
function loadProgressBar(){
myProgressBar = [
new ProgressBar("my_progress_bar_1",{
height: 400,
width: 129,
orientation: ProgressBar.Orientation.Vertical,
direction: ProgressBar.Direction.BottomToTop,
animationStyle: ProgressBar.AnimationStyle.StaticFull,
showLabel: false,
imageUrl: 'images/bottle-in.png',
markerUrl: 'images/marker-bottle.png',
extraClassName: {
wrapper: 'my_progress_bar',
left: 'my_progress_bar',
right: 'my_progress_bar',
middle: 'my_progress_bar',
marker: 'my_progress_bar',
parent: 'my_progress_bar',
background: 'my_progress_bar'
},
})
];
myProgressBar[0].setValue(currentValue);
}
loadProgressBar();
</script>
このコードを実行すると、空白のページが表示されます。誰か助けてくれませんか