Connecting Tech Pros Worldwide Help | Site Map

How to retrieve data from mysql database to plot jquery flot graph

Newbie
 
Join Date: Sep 2007
Posts: 27
#1: Aug 25 '09
Hello all
I am trying to retrieve the data from mysql database by php to plot a flot graph can anyone help me please this is all i have done for now
Php

Expand|Select|Wrap|Line Numbers
  1. $sql = mysql_query("SELECT count(Msg_ID) msgCount,Group_ID 
  2.                                       FROM Messages 
  3.                                         GROUP BY Group_ID");
  4.  
  5. $dataset1 = array();
  6.  
  7.  
  8.     while ($row = mysql_fetch_assoc($sql)) 
  9.     {
  10.         $dataset1[] = array( $row['msgCount'], $row['Group_ID'] );
  11.     }
  12.  print_r($dataset1);
  13.  
  14. jquery
  15.     function plotGraph()
  16.     {
  17.         alert("In body");
  18.         $.ajax({
  19.             url:"getData.php",
  20.             type:"post",
  21.             datatype:"json",
  22.             success:function(data)
  23.             {
  24.             $.plot($("#placeholder"), [ data ]);
  25.            },
  26.             error:function()
  27.             {alert("There was a problem");}
  28.         })
  29.     }
This draws the place holder but with no lines
Markus's Avatar
Moderator
 
Join Date: Jun 2007
Location: York, England, with wolves.
Posts: 4,936
#2: Aug 25 '09

re: How to retrieve data from mysql database to plot jquery flot graph


What do you get if you alert(data) in your success function. What kind of data does the plot need?
Newbie
 
Join Date: Sep 2007
Posts: 27
#3: Aug 25 '09

re: How to retrieve data from mysql database to plot jquery flot graph


I am just testing by count of messages for each group, so i guess it is integer
is that what you are asking for
Reply

Tags
flot, php