php - getting mysql results into Jpgraph -
i'm using jpgraph first time , trying mysql query results array code based on example bargradsmallex4.php. i've tried various syntax not overly familiar mysql_fetch_array() , can't insert data array. appreciated. query has been tested , produces results not query itself.
$sql= mysql_query('select agency,current,sum(current) table2 match(agency) against("health" in boolean mode) group agency '); // need data $datay = array(); while($row = mysql_fetch_array($sql)) $datay[] = array( 'current' => $row['sum(current)'], ); // setup graph. $graph = new graph(400,300); $graph->setscale("textlin"); $graph->img->setmargin(25,15,25,25); $graph->title->set('"grad_ver"'); $graph->title->setcolor('darkred'); // setup font axis $graph->xaxis->setfont(ff_font1); $graph->yaxis->setfont(ff_font1); // create bar pot $bplot = new barplot($datay); $bplot->setwidth(0.6); // setup color gradient fill style $bplot->setfillgradient("navy","lightsteelblue",grad_ver); // set color frame of each bar $bplot->setcolor("navy"); $graph->add($bplot); // send graph browser $graph->stroke();
i made changes in code.
1- setting alice sum(current)
2- setting while loop , $datay array.
please try it, gives required output.
$sql= mysql_query('select agency,current,sum(current) sum_of_current table2 match(agency) against("health" in boolean mode) group agency'); // need data $datay = array(); while($row = mysql_fetch_array($sql)) { $datay[] = $row['sum_of_current']; } // setup graph. $graph = new graph(400,300); $graph->setscale("textlin"); $graph->img->setmargin(25,15,25,25); $graph->title->set('"grad_ver"'); $graph->title->setcolor('darkred'); // setup font axis $graph->xaxis->setfont(ff_font1); $graph->yaxis->setfont(ff_font1); // create bar pot $bplot = new barplot($datay); $bplot->setwidth(0.6); // setup color gradient fill style $bplot->setfillgradient("navy","lightsteelblue",grad_ver); // set color frame of each bar $bplot->setcolor("navy"); $graph->add($bplot); // send graph browser $graph->stroke();
Comments
Post a Comment