<!-- <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> -->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>Flot Examples</title>
<link href="layout.css" rel="stylesheet" type="text/css">
<!--[if lte IE 8]><![endif]-->
<script type="text/javascript" src="./js/excanvas.min.js"></script>
<script type="text/javascript" src="./js/jquery.js"></script>
<script type="text/javascript" src="./js/jquery.flot.js"></script>
</head>
<body>
<h1>Flot Examples</h1>
<div id="placeholder" style="width:600px;height:300px;"></div>
<p>Simple example. </p>
<?php
$server = "localhost";
$user="harish";
$password="password";
$database = "db";
$connection = mysql_connect($server,$user,$password);
$db = mysql_select_db($database,$connection);
query = "SELECT xval,yval FROM flottable";
$result = mysql_query($query);
while($row = mysql_fetch_assoc($result))
{
$dataset1[] = array($row['xval'],$row['yval']);
}
?>
<script type="text/javascript">
$(function () {
var dataset1 = <?php echo json_encode($dataset1); ?>;
$.plot($("#placeholder"), [ dataset1 ]);
});
/* $(function () {
var d1 = [];
for (var i = 0; i < 14; i += 0.5)
d1.push([i, Math.sin(i)]);
$.plot($("#placeholder"), [ d1 ]); });
*/
</script>
</body>
</html>
伙计们,这是我的 jsp 代码,我正在尝试从我的数据库中检索数据并尝试从 3dyas 将其绘制在 FLOTCHART 上$row['yval'] 都正确地从 db 中获取值。但我仍然不知道如果我运行这个 jsp 文件为什么会绘制图表。我想我做错了什么我不知道我也在哪里用谷歌搜索从数据库中获取数据在javascript中,但我也得到了相同的结果,我们应该为此使用php,任何帮助或指导表示赞赏