Sign in to follow this  
Sir Jos

Display multiple charts on same page

Recommended Posts

I have multiple queries. How do I display these graphs on the same page from these queries. Currently, it only display one i.e Caption Question 2 graph instead of even the first i.e. Caption Question 1 graph. When I remove the code to display graph two i.e. Question 2 , then graph Caption Question 1 display. Any help please. See below code

 


<?php 

				    //Generate the chart element string

   $strXML = "";



   //Now, we get the data for the first question

   $sql = "SELECT ps_allanswers.answer as Answer, count(ps_answer.answer) AS Total FROM ps_allanswers LEFT OUTER JOIN ps_answer ON ps_answer.answer = ps_allanswers.answercode WHERE ps_allanswers.questionid = '1' GROUP BY ps_allanswers.answer, ps_allanswers.answercode ORDER BY ps_allanswers.answercode";

   $result = $db->exec_sql($sql);



   //Iterate through each factory

   if ($result) {

       while($ors = $db->fetch_assoc($result)) {

           //Here, we convert date into a more readable form for set label.

           $strXML .= "";

       }

   }



   //Close  element

   $strXML .= "";



   //Create the chart - Column 2D Chart with data from strXML

   echo renderChart("FusionCharts/Column3D.swf", "", $strXML, "OuestionA", 300, 300, false, false);





				?><?php 



				    //Generate the chart element string

   $strXML2 = "";



   //Now, we get the data for the first question

   $sql2 = "SELECT ps_allanswers.answer as Answer2, count(ps_answer.answer) AS Total2 FROM ps_allanswers LEFT OUTER JOIN ps_answer ON ps_answer.answer = ps_allanswers.answercode WHERE ps_allanswers.questionid = '2' GROUP BY ps_allanswers.answer, ps_allanswers.answercode ORDER BY ps_allanswers.answercode";

   $result2 = $db->exec_sql($sql2);



   //Iterate through each factory

   if ($result2) {

       while($ques2 = $db->fetch_assoc($result2)) {

           //Here, we convert date into a more readable form for set label.

           $strXML2 .= "";

       }

   }

   //mysql_close($link);



   //Close  element

   $strXML2 .= "";



   //Create the chart - Column 2D Chart with data from strXML

   echo renderChart("FusionCharts/Column3D.swf", "", $strXML2, "OuestionA", 300, 300, false, false);



				?>



Share this post


Link to post
Share on other sites

Hello Sir Jos,

 

I think you have to change the chart ID i.e. you have Question A for both the charts in the echorenderchart(), just change one to Question B or something.

 

 

 

Hope this helps.

 

 

 

thanks,

 

satish

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this