0

データベースに基づいて折れ線グラフを生成したい。初めてフュージョン チャートを使用するときは、フュージョン チャートのドキュメントにあるダイナミック チャートの手順に従います。これが私の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(): 6 is not a valid MySQL result resource in C:\xampp\htdocs\phpfusion\ramfusion\Chart.php 行 28 チャート。誰でもこの点で私を助けてくれませんか、よろしくお願いします、ラムサイ

4

2 に答える 2

1

行自体ではなく、行数(6)をループしようとしているためです。試す

while($row= mysql_fetch_assoc($result)){

代わりにあなたのループで。これにより、行の連想配列が返され、ループされて各行がに配置され$rowます。

于 2012-04-20T11:28:57.553 に答える
1

さらにいくつかのことを確認してください。

a) SWF へのパスが正しい。
b) FusionCharts.js がページに読み込まれます
。c) $strXML を TEXTAREA に出力して、適切な XML が生成されているかどうかを確認します。

于 2012-04-21T07:37:02.707 に答える