图表数据库数据连接

qhhrdooz  于 2021-06-18  发布在  Mysql
关注(0)|答案(0)|浏览(183)

我在连接mysql数据库到highstock时遇到了问题,这里是我的代码-当我运行它时,它不显示任何内容,只显示空页
有人能告诉我我做错了什么,或者给我发一个数据库连接脚本的例子吗?我真的很感激

<!DOCTYPE HTML>
<html>
	 	<body>
<script src="https://code.jquery.com/jquery-3.1.1.min.js"></script>
<script src="../../code/highstock.js"></script>
<script src="../../code/modules/exporting.js"></script>

<div id="container" style="height: 400px; min-width: 310px"></div>

		<script type="text/javascript">

<?php    $conn=mysqli_connect("localhost:3307","sampleuser","samplepass","sampledatabase");
if(!$conn)
{
	die("connection in error:".mysqli_connect_error());
}

$result=mysqli_query($conn,"Select time,open,close,high,low,volume From sampletable ");

while ($row = mysql_fetch_array($result)) {
   extract $row;
   $time *= 1000; // convert from Unix timestamp to JavaScript time
   $data[] = "[$time,$open,$close,$high,$low,$volume]";
}
?>

Highcharts.stockChart('container', {

        title: {
            text: 'AAPL stock price by minute'
        },

        rangeSelector: {
            buttons: [{
                type: 'hour',
                count: 1,
                text: '1h'
            }, {
                type: 'day',
                count: 1,
                text: '1D'
            }, {
                type: 'all',
                count: 1,
                text: 'All'
            }],
            selected: 1,
            inputEnabled: false
        },

        series: [{
            name: 'AAPL',
            type: 'candlestick',
            data: data,
            tooltip: {
                valueDecimals: 2
            }
        }]
    });

		</script>
	</body>
</html>

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题