0

I am trying to create a drill down, using Fusionchart and PHP from a MySQL database. I have worked over every error and now there are no errors but I still don't see my chart.

Please can someone tell my what could be the problem with my code. Below is are the code for the project starting with the link from the parent page.

$strXML .= "<set name = '".$row['Day']."' value = '".$row['TotOutput']."' link='" . urlencode("Detailed.php?Day=" . $row['Day']) . "'/>";


<?php
     //We have included ../Includes/FusionCharts.php and ../Includes/DBConn.php, which contains
     //functions to help us easily embed the charts and connect to a database.
      include("Includes/FusionCharts.php");
include("Includes/DBConn.php");
      ?>
      <HTML>
      <HEAD>
     <TITLE>    FusionCharts XT - Database and Drill-Down Example       </TITLE>
     <SCRIPT LANGUAGE="Javascript" SRC="../../FusionCharts/FusionCharts.js"></SCRIPT>
  </HEAD>
  <BODY>
  <?php
    //This page is invoked from Default.php. When the user clicks on a pie
   //slice in Default.php, the factory Id is passed to this page. We need
   //to get that factory id, get information from database and then show
   //a detailed chart.
   //First, get the factory Id
           //Request the factory Id from Querystring
           $day = $_GET['Day'];
           //Connect to database
           $link = connectToDB();
           //$strXML will be used to store the entire XML document generated
           //Generate the chart element string
           $strXML = "<graph caption='Peak Electricity Generated ---- for month April 2015' xAxisName='Day' yAxisName='MegaWatts' decimalPrecision='0' formatNumberScale='0' yaxismaxvalue='1000' showNames='1' rotateNames='1'>";

           //Now, we get the data for that plant
           $strQuery = "select plant_id, peak_generation from daily_report where pdate=" . $day;
           $result = mysql_query($strQuery) or die(mysql_error());

           //Iterate through each factory
           if ($result) {
              while($ors = mysql_fetch_array($result)) {

                  $strQuery = "plant_name from power_plant where plant_id=" . $ors['plant_id'];
           $result2 = mysql_query($strQuery) or die(mysql_error());
           $ors2 = mysql_fetch_array($result2);


                 //Here, we convert date into a more readable form for set label.
                 $strXML .= "<set name = '".$ors2['plant_name']."' value = '".$ors['peak_generation']."'/>";
              }
           }
           mysql_close($link);
           //Close <chart> element
           $strXML .="</graph>";
           //Create the chart - Column 2D Chart with data from $strXML
           echo renderChart("charts/FCF_Line.swf", "", $strXML, "Daily Output", 1300, 500);
        ?>
  </CENTER>
  </BODY>
</HTML>
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Please, [stop using `mysql_*` functions](http://stackoverflow.com/questions/12859942/why-shouldnt-i-use-mysql-functions-in-php). They are no longer maintained and are [officially deprecated](https://wiki.php.net/rfc/mysql_deprecation). Learn about [prepared statements](http://en.wikipedia.org/wiki/Prepared_statement) instead, and use [PDO](http://jayblanchard.net/demystifying_php_pdo.html). – Jay Blanchard Apr 27 '15 at 21:44
  • thanks i have gone through the tutorials but might take slight time to get use to. but with the current version of mysql_ function, would it be possible to achieve my goal still? – Galli Pedro Apr 27 '15 at 22:22
  • I haven't seen upper-case HTML for about fifteen years - this will work, but why not write it in lower-case, like everyone else? HTML4 is pretty old now `:-)`. Since I am on the topic of case, if you could avoid writing questions in all-lower-case, that would be great - we like posts to be as readable as possible here. Thanks! – halfer Apr 27 '15 at 23:02
  • Oops, `` is pretty old too! There is no opening tag, but this also needs removing. Use CSS instead. – halfer Apr 27 '15 at 23:03
  • Does your `FCF_Line.swf` Flash file make an HTTP fetch for the generated XML file? (I presume that's how it works). You can see HTTP ops in your browser using your network panel. – halfer Apr 27 '15 at 23:12

0 Answers0