我想连接到数据库并使用 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>
此代码在我运行时显示空白页。有人可以帮我吗