juniordev Report post Posted April 4, 2011 Hi i am basically trying to create a simple line graph by gathering data from SQL server, the data itself which i would like to show is, CPU Load percentage which allows me to view over a day what the CPU usage has been like in my webpage. I am using php on wamp server. and i really do not know what i am doing wrong, new to php,new to html, new to most! so would love some help from you veterans!! Really appreciate it. Basically what i am trying to achieve is when you go to task manager, the performance tab shows a CPU line graph, that is all i want! in the most simplest way! In my database i have data for LoadPercentage as you can see below which at the moment is not under any time frame, i am just using any data to have a graph working at first if you know what i mean. CHEERS GUYS (note i did not include connection inc.php) i think the coding is right but you guys will tell me wrong right! <?php include("\FusionCharts\FusionCharts_PHP\App\Includes\FusionCharts.php"); ?> <HTML> <HEAD> <TITLE>FusionCharts Free - Database Example</TITLE> <script LANGUAGE="Javascript" SRC="./FusionCharts/Charts/FusionCharts.js"></SCRIPT> </HEAD> <BODY> <CENTER> <?php //In this example, we show how to connect FusionCharts to a database. //For the sake of ease, we've used a MySQL database containing two //tables. //Connect to the DB $serverName = "CWIHQLA3FF813J\SQLEXPRESS"; $connectionOptions = array("Database" => "PerfMon"); $conn = sqlsrv_connect( $serverName, $connectionOptions) or die ("<p>Problem on connecting to database</p>"); //$strXML will be used to store the entire XML document generated //Generate the graph element $strXML = "<graph caption='Factory Output report' subCaption='By Quantity' decimalPrecision='0' showNames='1' numberSuffix=' Units' pieSliceDepth='30' formatNumberScale='0'>"; //Fetch all factory records $queryString = "SELECT TOP 100 LoadPercentage FROM [PerfMon].[dbo].[CPUUsage]"; $result = sqlsrv_query($conn, $queryString) or die ("Problem in executing query"); //Iterate through each factory if ($result) { while($ors = sqlsrv_fetch_array($result)) { //Generate <set name='..' value='..'/> $strXML .= "<set name='CPU Usage' value='" . $ors['LoadPercentage'] . "' />"; } } sqlsrv_close($conn); //Finally, close <graph> element $strXML .= "</graph>"; //Create the chart - Pie 3D Chart with data from $strXML echo renderChart("\FusionCharts\Charts\Line.swf", "", $strXML, "LoadPercentage", 650, 450, "", ""); ?> </BODY> </HTML> Share this post Link to post Share on other sites