dongzanghui4624 2012-04-20 10:37
浏览 57
已采纳

图表不会在php和mysql中生成融合图表

I want to generate line graph based on database. First time i am using fusion charts, i follow the procedure for the dynamic charts in fusion charts documentation. Here is my php page code:

<?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>

I am getting error as: Warning: mysql_num_rows(): 6 is not a valid MySQL result resource in C:\xampp\htdocs\phpfusionamfusion\Chart.php on line 28 Chart. Can anyone please help me in this regard, Thank you in advance, Ramsai

  • 写回答

2条回答 默认 最新

  • du9698 2012-04-20 11:28
    关注

    Because your trying to loop over the number of rows (6) rather than the rows themselves. Try

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

    instead on your loop. This will return an associative array of the rows, which will then get looped over, placing each row into $row.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥20 完全没有学习过GAN,看了CSDN的一篇文章,里面有代码但是完全不知道如何操作
  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行