anzi, aggiungo:
l'include della connessione al db non vi fa vedere una fava.
vanno fatte tante connessioni al db quanti sono gli array, altrimenti sto script non funziona.
eccovi l'esempio:
Codice PHP:
<?php
include("phpgraphlib.php");
$graph=new PHPGraphLib(450,300);
$link = mysql_connect('localhost', '', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('publigest') or die('Could not select database');
$dataArray=array();
$sql="SELECT a.mese, b.ricavo_prev FROM mesi a, budget_generale b WHERE a.id_mese = b.id_mese ORDER BY a.mese DESC";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_assoc($result))
{
$mese=$row["mese"];
$count=$row["ricavo_prev"];
//ADD TO ARRAY
$dataArray[$mese]=$count;
}
$link = mysql_connect('localhost', '', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('publigest') or die('Could not select database');
$dataArray2=array();
$sql="SELECT a.mese, b.costo_prev FROM mesi a, budget_generale b WHERE a.id_mese = b.id_mese ORDER BY a.mese DESC";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_assoc($result))
{
$mese=$row["mese"];
$count=$row["costo_prev"];
//ADD TO ARRAY
$dataArray2[$mese]=$count;
}
$link = mysql_connect('localhost', '', '')
or die('Could not connect: ' . mysql_error());
mysql_select_db('publigest') or die('Could not select database');
$dataArray3=array();
$sql="SELECT a.mese, b.costo_real FROM mesi a, budget_generale b WHERE a.id_mese = b.id_mese ORDER BY a.mese DESC";
$result = mysql_query($sql) or die('Query failed: ' . mysql_error());
while($row = mysql_fetch_assoc($result))
{
$mese=$row["mese"];
$count=$row["costo_real"];
//ADD TO ARRAY
$dataArray3[$mese]=$count;
}
$graph->addData($dataArray,$dataArray2,$dataArray3);
$graph->setBackgroundColor("black");
$graph->setBarColor("255,255,204");
$graph->setTitle("Budget riassuntivo");
$graph->setTitleLocation("left");
$graph->setLegend(true);
$graph->setLegendTitle("Previsto", "Pianificato", "Reale");
$graph->setTitleColor("yellow");
$graph->setupYAxis(12, "yellow");
$graph->setupXAxis(20, "yellow");
$graph->setXValuesHorizontal(true);
$graph->setGrid(false);
//$graph->setGoalLine(60);
//$graph->setGoalLineColor("yellow");
$graph->setGradient("gray", "white");
$graph->setBarOutlineColor("white");
$graph->setTextColor("white");
$graph->createGraph();
?>
non so perchè, ma se metto in include il mio file conn.php (che su altre cose nella pagina funziona benissimo), lo script non funziona.
Spero che vi sia di aiuto....
Fabri