﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>FusionCharts Forum / FusionCharts v3 / Using FusionCharts / FusionCharts and PHP  / Simple PHP+MySQL charts / Latest Posts</title><generator>InstantForum.NET v4.1.4</generator><description>FusionCharts Forum</description><link>http://www.fusioncharts.com/forum/</link><webMaster>support@fusioncharts.com</webMaster><lastBuildDate>Wed, 07 Jan 2009 17:27:11 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: Simple PHP+MySQL charts</title><link>http://www.fusioncharts.com/forum/Topic274-31-1.aspx</link><description>&lt;FONT face=Arial&gt;Here are a sample of code I have written to get my charts to populate.&lt;/FONT&gt;&lt;P&gt;&lt;FONT face=Arial&gt;This is a simple 2D pie chart with v3 charts.  There are two seperate files, one is a data file and the other displays the chart and other html items on the viewable page.  What this code is from is the data file.  Hope it helps you out.&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;[code]&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;&amp;lt;?php&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;session_start(); // used to start a session for security reasons&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;include ('login.php'); // security files&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;include ('names.php'); //misc files&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;include './includes/Connection_'.$conn.'.php'; // connection file with functions&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;include './includes/chart_colors.php';&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// get the variables posted in the page form; prepend 'r_' to them&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;import_request_variables("gp", "r_");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$date = date("m/d/y");&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// get the customer data&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// query the MySQL database&lt;BR&gt;$query = "SELECT SUM((qty_ord - qty_ship) * line_price) as sales, reason_code, reason_group, &lt;BR&gt;reason_name FROM sales_late_orders WHERE closed = 'no' GROUP BY reason_group, reason_name";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// result of the query&lt;BR&gt;$result = db_query($query, $DBLink) or die ('Error: Cannot get Data!');&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// generate the XML for the chart&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$strXML = "&amp;lt;graph caption='Late Orders by Reason ".$date."' useRoundEdges='1' chartLeftMargin='0' &lt;BR&gt;chartRightMargin='5' chartTopMargin='0' chartBottomMargin='0' decimalPrecision='0' &lt;BR&gt;showPercentageValues='0' showNames='1' rotateNames='1' numberPrefix='".$symbol."' &lt;BR&gt;showPercentageInLabel='0' canvasBgColor='FFFFFF,".$_GET["daColor"]."' canvasBgAngle='270' &lt;BR&gt;canvasBgAlpha='90' bgColor='".$strColor[10]."' showAlternateHGridColor='0' showBorder='0' &lt;BR&gt;baseFontSize='12' baseFontColor='".$strColor[8]."'&amp;gt;";&lt;/FONT&gt;&lt;/P&gt;&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT face=Arial&gt;// connection settings for other servers&lt;BR&gt;if ($hostname == "192.168.5.50") {&lt;BR&gt;switch ($cCo) {&lt;/FONT&gt;&lt;/P&gt;&lt;P dir=ltr style="MARGIN-RIGHT: 0px"&gt;&lt;FONT face=Arial&gt;case "csgc":&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$file = "csgc/";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;break;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;case "ucl":&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$file = "csgw/";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;break;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// as long as there is a result in the row (function called out in the connection file) it will keep doing the loop&lt;BR&gt;&lt;BR&gt;while ($row = db_fetch_assoc($result)){&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// append the data&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;if ($row["reason_code"] == 0){&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$reason = "Unassigned";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;else {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;if ($row["reason_group"] == $row["reason_name"]) {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$reason = $row["reason_group"];&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;else {&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$reason = $row["reason_group"]." - ".$row["reason_name"];&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;}&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$htmlLink = "[url]&lt;/FONT&gt;&lt;U&gt;&lt;FONT color=#0000ff&gt;&lt;FONT face=Arial&gt;http://".$hostname."/cgi-bin/wspd_cgi.sh/WService=ws".$broker."/dash/".$file."reason1.html?cReason=".$row["reason_code"]&lt;/FONT&gt;&lt;/U&gt;&lt;/FONT&gt;&lt;FONT face=Arial&gt;[/url];&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$strXML = $strXML."&amp;lt;set value='".$row["sales"]."' name='".$reason."' link='".$htmlLink."' /&amp;gt;"; }&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// close tags&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// concatenate to form the whole XML document&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$strXML = $strXML;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;$strXML = $strXML."&amp;lt;/graph&amp;gt;";&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;// output the data&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;echo($strXML);&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT face=Arial&gt;?&amp;gt;&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;[/code]</description><pubDate>Mon, 25 Jun 2007 09:14:04 GMT</pubDate><dc:creator>b471code3</dc:creator></item><item><title>RE: Simple PHP+MySQL charts</title><link>http://www.fusioncharts.com/forum/Topic274-31-1.aspx</link><description>You can see the Array or Form examples. Those are simple examples.&lt;/P&gt;&lt;P&gt;I'm afraid we do NOT have anything simpler than that.</description><pubDate>Tue, 06 Feb 2007 12:52:32 GMT</pubDate><dc:creator>Pallav</dc:creator></item><item><title>RE: Simple PHP+MySQL charts</title><link>http://www.fusioncharts.com/forum/Topic274-31-1.aspx</link><description>That's why I ask for more simple examples the existed on document is too complicated for me :crying:  PLEASE show me some SIMPLE-1-table database chart plotting.:D</description><pubDate>Mon, 05 Feb 2007 11:15:20 GMT</pubDate><dc:creator>CJL999</dc:creator></item><item><title>RE: Simple PHP+MySQL charts</title><link>http://www.fusioncharts.com/forum/Topic274-31-1.aspx</link><description>You may please see &lt;A href="http://www.fusioncharts.com/FusionCharts/Docs"&gt;http://www.fusioncharts.com/FusionCharts/Docs&lt;/A&gt; &amp;gt; Guide for Web Developers &amp;gt; FusionCharts and PHP. We've lot of simple and easy-to-grasp examples with documentation.</description><pubDate>Mon, 05 Feb 2007 06:37:07 GMT</pubDate><dc:creator>Pallav</dc:creator></item><item><title>Simple PHP+MySQL charts</title><link>http://www.fusioncharts.com/forum/Topic274-31-1.aspx</link><description>Hi there, I'm new using FusionCharts with mysql database. I've seen an example on the document but I still confuse fetching data from mysql to the chart. Can anyone give me some basic  database example using php+mysql? I just want to learn how to plot a simple pie chart or bar chart with couple of data. &lt;br&gt;&lt;br&gt;best regards.;)</description><pubDate>Sun, 04 Feb 2007 12:13:40 GMT</pubDate><dc:creator>CJL999</dc:creator></item></channel></rss>