1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50
|
<?php
include ("C:\Users\Joe\Desktop\Projets\Site\jpgraph.php");
include ("C:\Users\Joe\Desktop\Projets\Site\jpgraph_line.php");
//acces à la base de données
$id_connexion = mysql_connect ('127.0.0.1',"root","mysql");
mysql_select_db("test",$id_connexion);
//requête
$requete = mysql_query("SELECT y FROM tonne");
$i=0;
while ($donnees=mysql_fetch_array($requete))
{
$y [$i++]=$donnees ['y'];
{
$result = $donnees['y'];
echo $result.",";
}
//$ydata = array();
}
foreach ($y as $value)
$lol = $value;
echo $lol."" ;
$ydata = array($lol);
$xdata = array('JAN','FEV','MAR','AVR','MAI','JUN','JUI','AOU','SEP','OCT','NOV','DEC');
// Creation du graphique
$graph = new Graph(800,600);
$graph->img->SetMargin(40,30,50,40);
$graph->SetScale("textlin");
// Création du système de points
$lineplot=new LinePlot($requete);
//X names
$graph->xaxis->title->Set("Mois");
$graph->xaxis->SetTickLabels($xdata);
// On rajoute les points au graphique
$graph->Add($lineplot);
// Affichage
$graph->Stroke();
//close le mysql
mysql_close ();
?> |
Partager