Simple PHP+MySQL charts
FusionCharts Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Simple PHP+MySQL charts Expand / Collapse
Author
Message
Posted 2/4/2007 12:13:40 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/16/2007 12:11:50 PM
Posts: 2, Visits: 11
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.

best regards.
Post #274
Posted 2/5/2007 6:37:07 AM
FusionCharts Team

FusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts Team

Group: Administrators
Last Login: Yesterday @ 8:20:12 AM
Posts: 2,194, Visits: 521
You may please see http://www.fusioncharts.com/FusionCharts/Docs > Guide for Web Developers > FusionCharts and PHP. We've lot of simple and easy-to-grasp examples with documentation.

Thanks,
Pallav Nadhani
FusionCharts Team
Post #276
Posted 2/5/2007 11:15:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 2/16/2007 12:11:50 PM
Posts: 2, Visits: 11
That's why I ask for more simple examples the existed on document is too complicated for me PLEASE show me some SIMPLE-1-table database chart plotting.
Post #281
Posted 2/6/2007 12:52:32 PM
FusionCharts Team

FusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts Team

Group: Administrators
Last Login: Yesterday @ 8:20:12 AM
Posts: 2,194, Visits: 521
You can see the Array or Form examples. Those are simple examples.

I'm afraid we do NOT have anything simpler than that.

Thanks,
Pallav Nadhani
FusionCharts Team

Post #288
Posted 6/25/2007 9:14:04 AM
Junior Member

Junior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior MemberJunior Member

Group: Forum Members
Last Login: 8/30/2007 11:48:12 AM
Posts: 10, Visits: 16
Here are a sample of code I have written to get my charts to populate.

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.

<?php

session_start(); // used to start a session for security reasons

include ('login.php'); // security files

include ('names.php'); //misc files

include './includes/Connection_'.$conn.'.php'; // connection file with functions

include './includes/chart_colors.php';

// get the variables posted in the page form; prepend 'r_' to them

import_request_variables("gp", "r_");

$date = date("m/d/y");

// get the customer data

// query the MySQL database
$query = "SELECT SUM((qty_ord - qty_ship) * line_price) as sales, reason_code, reason_group,
reason_name FROM sales_late_orders WHERE closed = 'no' GROUP BY reason_group, reason_name";

// result of the query
$result = db_query($query, $DBLink) or die ('Error: Cannot get Data!');

// generate the XML for the chart

$strXML = "<graph caption='Late Orders by Reason ".$date."' useRoundEdges='1' chartLeftMargin='0'
chartRightMargin='5' chartTopMargin='0' chartBottomMargin='0' decimalPrecision='0'
showPercentageValues='0' showNames='1' rotateNames='1' numberPrefix='".$symbol."'
showPercentageInLabel='0' canvasBgColor='FFFFFF,".$_GET["daColor"]."' canvasBgAngle='270'
canvasBgAlpha='90' bgColor='".$strColor[10]."' showAlternateHGridColor='0' showBorder='0'
baseFontSize='12' baseFontColor='".$strColor[8]."'>";

// connection settings for other servers
if ($hostname == "192.168.5.50") {
switch ($cCo) {

case "csgc":

$file = "csgc/";

break;

case "ucl":

$file = "csgw/";

break;

}

}

// as long as there is a result in the row (function called out in the connection file) it will keep doing the loop

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

// append the data

if ($row["reason_code"] == 0){

$reason = "Unassigned";

}

else {

if ($row["reason_group"] == $row["reason_name"]) {

$reason = $row["reason_group"];

}

else {

$reason = $row["reason_group"]." - ".$row["reason_name"];

}

}

$htmlLink = "" target=_"blank" class="SmlLinks">http://".$hostname."/cgi-bin/wspd_cgi.sh/WService=ws".$broker."/dash/".$file."reason1.html?cReason=".$row["reason_code"];

$strXML = $strXML."<set value='".$row["sales"]."' name='".$reason."' link='".$htmlLink."' />"; }

// close tags

// concatenate to form the whole XML document

$strXML = $strXML;

$strXML = $strXML."</graph>";

// output the data

echo($strXML);

?>

Post #1422
« Prev Topic | Next Topic »


Permissions Expand / Collapse

All times are GMT -7:00, Time now is 6:16pm


Execution: 0.031.