homepage Welcome to WebmasterWorld Guest from 54.211.97.242
register, free tools, login, search, pro membership, help, library, announcements, recent posts, open posts,
Become a Pro Member

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
Forum Library, Charter, Moderator: open

Flash and Shockwave Forum

    
Open Flash Chart / SQL Database
Using SQL database to populate a chart
robbiesqp



 
Msg#: 4186069 posted 5:42 pm on Aug 12, 2010 (gmt 0)

Disclaimer: I'm a noob.

I've been interning at a company throughout the summer developing a website that will display various data from some buoys. The data is stuff like latitude, longitude, water temperature, depth, etc.

I'd like to display this data in an "Open Flash Chart" chart. I'm not sure if you're familiar with that application or not, here is a link to their official site: [teethgrinder.co.uk ] (note: I'm using the older version of Open Flash Chart, not Open Flash Chart 2)

The reason I'm even using this particular application to display charts in the first place is someone here at the company had set it up beforehand. If someone can offer a better alternative for what I am trying to do, like using something besides Open Flash Chart, that would be awesome.

I have an SQL database already set up, it's all good to go. All I want to do is take the last 25 rows or so and pull data from that. The database has thousands upon thousands of rows, because it's updated with every new data report from a buoy.

In this Open Flash Chart application, I can get the chart to work if I just use a text file, but I really need it to be able to get the data from a database.

Here is a small sample of the code from one of the chart.php files:

$link = mysql_connect("localhost","root","password") or die(mysql_error());
mysql_select_db("riverine",$link);
$query="select * from data order by uid asc limit 1";
$result=mysql_query($query,$link) or die(mysql_error());

while ($track = mysql_fetch_array($result))
{
$lat = $row['lat'];
$long = $row['long'];

$n = count($lat);

$ymax = $lat[1];
$ymin = $lat[1];
$xmax = $long[1];
$xmin = $long[1];
$j = 0;
echo $n;

for ($i=0; $i<$n; $i++)
{


$track[$i] = new point ($long[$i], $lat[$i] , 3);
if ($lat[$i] >= $ymax)
{
$ymax = $lat[$i] + .0001;
}
if ($long[$i] >= $xmax)
{
$xmax = $long[$i] + .0001;
}

if ($lat[$i] <= $ymin)
{
$ymin = $lat[$i] - .0001;
}
if ($long[$i] <= $xmin)
{
$xmin = $long[$i] - .0001;
echo $xmin;
echo nl2br ("x min \n");
}

}


Connecting to the SQL database is no problem. But I'm sure I'm just doing something wrong with forming the array and setting the xmin, xmax, ymin, ymax for the table. I really don't know if I can describe this any better than I have. If anyone is familiar with Open Flash Chart, perhaps you can help me. But I'm wondering if Open Flash Chart can even work with SQL databases like I want it to. I've looked up the documentation on their site and haven't found anything particularly helpful.

Any ideas, suggestions, help is greatly appreciated. I'm on a pretty tight deadline to get this thing finished before I go back to school for the fall and I'm stressing like crazy. I'm just so new to all this. Thank you for your help.

 

rocknbil

WebmasterWorld Senior Member rocknbil us a WebmasterWorld Top Contributor of All Time 10+ Year Member



 
Msg#: 4186069 posted 6:40 pm on Aug 13, 2010 (gmt 0)

Not familar with the flash product, sorry . . . but a couple small(ish) things I don't grok.

$lat = $row['lat'];
$long = $row['long'];

OK . . so you have scalar values for $lat and $long. Not arrays (lists,) but single values. Then you do

$n = count($lat);

which (should?) always give you a 1 . . or maybe even a warning/error since it's not an array, nothing to count. Then where you really lose me is

$ymax = $lat[1];
$ymin = $lat[1];
$xmax = $long[1];
$xmin = $long[1];

Which indicates, to me, you have either previously defined the array $lat and $long - which you just killed and re-set as a scalar above - and are setting your x/y's to the second member in these arrays. Which don't exist. For example

$lat = new Array();
$lat[1] = 'some_value';

Since there's no zero'th (first) member, the array $lat is now

[null,'some value']

So my point is, from the code you have there, all four of your x/y values . . . should be null.

Deal's off for me at that point, I don't get it. :-) But further on, echo $n gives you a 1, right? OR is it null? (Never tried to count a scalar.)

for ($i=0; $i<$n; $i++)

So this should go through once. 0 < 1 is true. But there's no member at $long[0] or $lat[0].

The final point of "where am I, what am I doing" is this.

$track[$i] = new point ($long[$i], $lat[$i] , 3);

This indicates you have to have some class with a function or constructor for "point." I looked, no PHP function "point."

Maybe more info is required, dass' all I got.

Global Options:
 top home search open messages active posts  
 

Home / Forums Index / Code, Content, and Presentation / Flash and Shockwave
rss feed

All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
Home ¦ Free Tools ¦ Terms of Service ¦ Privacy Policy ¦ Report Problem ¦ About ¦ Library ¦ Newsletter
WebmasterWorld is a Developer Shed Community owned by Jim Boykin.
© Webmaster World 1996-2014 all rights reserved