Sign in to follow this  
deiffert

Query MYSQL, return chart - HELP

Recommended Posts

I'm looking to query a database with a product number, and return the data form that product in a graph.

 

 

 

Here's the deal:

 

I work for an electronics retailer. Every week we go out an collect the prices of our competitors to ensure that we are the lowest price (a few hundred different products). We want to create a database with this data and our own prices and have a site where our sales guys can enter a product # in and it will return a line graph with our price and the prices from our competitors over the last however many months.

 

 

 

I've seen and gone through the PHP/Database examples, but can't find any references on how to query a database with an input field and return a graph with that data.

 

 

 

Any thoughts?

 

Thanks.

Share this post


Link to post
Share on other sites

UPDATE: I have the php file reading from the mysql database just fine, i'm just not sure how to format the xml string to work.

 

 

 

 

 

 

//Request the factory Id from Querystring

 

$ProductId = $_GET['ProductId'];

 

 

 

//Generate the chart element string

 

$strXML = "";

 

 

 

// Connect to the DB

 

$link = connectToDB();

 

 

 

//Now, we get the data for that factory

 

$strQuery = "select * from Product_Master where ProductId=" . $ProductId;

 

$result = mysql_query($strQuery) or die(mysql_error());

 

 

 

//Iterate through each factory

 

if ($result) {

 

while($ors = mysql_fetch_array($result)) {

 

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

 

$strXML .= "**less than symbol here**set label='" . $ors['Company'] . "' value='" . $ors2['Date'] . "' value='" . $ors2['Price'] . "' /**greater than symbol here**";

 

}

 

}

 

mysql_close($link);

 

 

 

//Close element

 

$strXML .= "";

 

 

 

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

 

echo renderChart("../../FusionCharts/Column2D.swf", "", $strXML, "FactoryDetailed", 600, 300, false, false);

 

?>

 

 

 

 

 

 

I had to replace this: < with: **less than symbol here** because it wasn't showing up right for some reason. in my real code, it's correct.

 

 

 

I'm fairly certain that the problem is that my strXML string isn't being generated properly. I've just been using some trial and error here, so the string is probably totally jacked up at this point.

 

 

 

Please let me know what you think.

 

 

 

Thanks,

 

- David

Share this post


Link to post
Share on other sites

Hi,

Most probably you are right. can you please let us see the XML that's getting concatenated in $strXML?

YOu can add this to ge the XML in a textarea and copy this in a txt file and attach to this post so that it can be clearly analyzed.

echo "<textarea rows='50' cols='30'>$strXML</textarea>";

Thanks

Share this post


Link to post
Share on other sites

Hi,

 

Thanks for the response.

 

 

 

I contact FusionCharts directly and they helped me get it all worked out. It's working great now! :)

 

 

 

Thanks,

 

- David

Share this post


Link to post
Share on other sites

i hav used the HTML ISO-8859-1 reference Codes for all other symbols like (">","?","@","#")

i have used  > for greater than symbol its working so fine.

similarly i have tried < for less than but its not working..

please help me..

thanks in advance

 

 

 

Share this post


Link to post
Share on other sites
Guest Rajroop

Hello,

Could you please use '<' for the less than symbol and try again?

I hope this helps. :)

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