我想根據數據庫生成線圖。第一次我使用融合圖表時,我按照融合圖表文檔中動態圖表的步驟進行操作。這裏是我的PHP頁面代碼:圖不在php和mysql中生成融合圖
<?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():6是不是在C一個有效的MySQL結果資源:\ XAMPP \ htdocs中\ phpfusion \ ramfusion \ Chart.php在線28 圖表。 任何人都可以請幫我在這方面, 謝謝你在前進, Ramsai
@ paystay,非常感謝您的回覆,我更改爲while($ row = mysql_fetch_assoc($ result)){ 但它仍然會拋出相同的錯誤。 – ramsai 2012-04-20 11:35:42
你發佈的代碼是Chart.php吧?第28行是mysql_num_rows開啓的行,我建議改爲上面的行。如果這一切都是正確的你不應該得到這個錯誤仍然更新你的代碼在你的問題,我們會看看 – Paystey 2012-04-20 12:08:48
現在我沒有得到任何錯誤,但PHP頁面不讀取XML標籤中的數據我認爲,我再次給我的修改chart.php頁面: – ramsai 2012-04-20 12:38:39