Multi-Series with MySQL Database :: URGENT!
FusionCharts Forum
Home       Members    Calendar    Who's On
Welcome Guest ( Login | Register )
        



Multi-Series with MySQL Database :: URGENT! Expand / Collapse
Author
Message
Posted 4/4/2008 5:28:27 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 4/9/2008 2:58:47 AM
Posts: 3, Visits: 5
Can anyone urgently help me please? I want to use the multi-series option of FusionCharts and connect it to my database. This is what my table looks like:


months            units   stationName

January14,629 Station 1
February19,161 Station 1
March13,388 Station 1
April10,522 Station 1
May15,941  Station 1
June10,650 Station 1
July11,005 Station 1
August19,141 Station 1
September13,228 Station 1
October22,452 Station 1
November15,757 Station 1
December20,464 Station 1
January    15,654  Station 2
February16,718 Station 2
March14,839 Station 2
April12,791 Station 2
May12,838 Station 2
June14,229 Station 2
July15,616 Station 2
August14,633 Station 2
September19,544 Station 2
October16,592 Station 2
November14,746 Station 2
December15,425 Station 2
January233,796 Station 3
February82,309 Station 3
March198,876 Station 3
April34,959 Station 3
May367,101 Station 3
June430,691 Station 3
July220,664 Station 3
August318,963 Station 3
September106,403 Station 3
October248,531 Station 3
November339,486 Station 3
December174,552 Station 3
January190,048 Station 4
February38,460 Station 4
March178,998 Station 4
April49,516 Station 4
May256,988 Station 4
June307,099 Station 4
July201,678 Station 4
August215,608 Station 4
September108,847 Station 4
October222,191 Station 4
November235,785 Station 4
December103,880 Station 4

I'm struggling to get the info from the table. Here's PHP the code I used:

# Months
 
  $strQuery = "SELECT distinct months FROM stations_new";
  $result = mysql_query($strQuery);
 
  # Add category names
  $FC->addCategoryFromDatabase($result, "months");

 
  # Stations
 
  # Create a new dataset

  $strQuery = "select units, months, stationName from stations_new GROUP BY stationName";
  $result = mysql_query($strQuery);
  $FC->addDatasetsFromDatabase($result, "stationName", "units");

 
  
  # Add chart values for the above dataset
 
 
  $strQuery = "select months, units, stationName from stations_new";
  $result = mysql_query($strQuery);
  $FC->addDataFromDatabase($result, "units");

This code is not working at all. What am I doing wrong? Is there anyway to simplify the table structure? The table above is very cumbersome. Eventually I would need it to be by week and days of the year. To do that the table would be 365 x 4 rows long. Is there a better way to do this?

Thanks!

Karen

Post #5449
Posted 4/7/2008 12:15:02 AM
Supreme Being

Supreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme BeingSupreme Being

Group: Moderators
Last Login: Today @ 8:31:36 AM
Posts: 763, Visits: 1,214
Hi,

Could you please try changin the SQL :

$strQuery = "select units, months, stationName from stations_new ORDER BY stationName";


Regards,

Sudipto Choudhury
FusionCharts Team

Post #5466
Posted 4/7/2008 12:48:33 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 4/9/2008 2:58:47 AM
Posts: 3, Visits: 5
Hi,

Thanks for your reply. I've changed the code as you requested and this is what I get:

At least it's picking up on all four stations per month but it's not recognizing the units. Any insight why this could be?

Thanks!
Karen

Post #5467
Posted 4/8/2008 10:26:08 PM
FusionCharts Team

FusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts TeamFusionCharts Team

Group: Administrators
Last Login: 7/29/2008 12:15:49 PM
Posts: 2,001, Visits: 474
Is your data in XML purely numeric - without any currency or comma signs?

Thanks,
Pallav Nadhani
FusionCharts Team
Post #5520
Posted 4/9/2008 2:26:49 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: Forum Members
Last Login: 4/9/2008 2:58:47 AM
Posts: 3, Visits: 5
Hi Pallav,

I had look at my data and there were commas in it. I've taken it out and now it works fine. Thank you for that insight! My other question though, my table of data (as I posted in my first post above) is very lob-sided. Is there an easier way to structure my table?

Thanks!
Karen

Post #5536
« Prev Topic | Next Topic »


Permissions Expand / Collapse