我想基于数据库生成折线图。第一次使用融合图时,我遵循融合图文档中动态图的过程。这是我的php页面代码:
<?php
include("Includes/FusionCharts.php");
include("Includes/DBconn.php");
?>
<html>
<title> Blood Pressure</title>
<head>
<script language="javascript" src="FusionCharts/FusionChart.js"></script>
</head>
<body>
<center>
<?php
//connect to the DB
$link= connectToDB();
//$strXML will be used to store the entire XML document generated
//Generate the graph element
$strXML = "<graph caption='Blood Pressure Reading' subCaption='By Patient'xaxisname='Months' yaxisname='Blood Pressure' hovercapbg='F5589A' hovercapborder='F5589A' rotateNames='1' yAxisMaxValue='200'>";
//Fetch records from database
$query= "select * from patient_health";
$result = mysql_query($query) or die(mysql_error());
echo $result;
//Iterate through each patient blood pressure systole
while($row= mysql_num_rows($result)){
//Generate the setname and value
// echo $row['Date'];
//echo $row['Systole_reading'];
$strXML.="<set name='".$row['Date']."'value='". $row['Systole_reading']."'/>";
mysql_free_result($result);
}
//Finally, close <graph> element
$strXML .= "</graph>";
//Create the chart - Pie 3D Chart with data from $strXML
echo renderChart("FusionCharts/FCF_Line.swf", "", $strXML, "BloodPressure", 650, 450);
?>
</center>
</body>
</html>
我收到以下错误消息:
警告:mysql_num_rows():第28行的C:\ xampp \ htdocs \ phpfusion \ ramfusion \ Chart.php中的6不是有效的MySQL结果资源
图表。
任何人都可以在这方面帮助我,
先感谢您,
拉姆赛
最佳答案
因为您试图遍历行数(6),而不是行本身。尝试
while($row= mysql_fetch_assoc($result)){
而是在您的循环上。这将返回行的关联数组,然后将其循环,将每一行放入
$row
中。关于php - 在融合图表的php和mysql中未生成图形,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/10244609/