par
chris52 » 30 sept. 2014, 09:22
Bonjour à tous,
Inutile de vous dire que je suis complètement desespéré je transpire le code tellement ça deviens compliqué pour moi !
Donc je vous explique je voudrais faire un outil de statistique qui irai chercher les infos dans une bdd (que je ne controle pas) et qui les afficherais sous forme de diagramme. L'affichage du diagramme fonctionne SAUF que mes valeurs sont fausse ou tout du moins elles sont bonne que pour le mois courant et mon diagramme n'affiche pas non plus les valeurs des mois derniers ! Ma requete doit etre fausse ensuite mon code n'est pas tres beau j'en suis conscient !
voici ma bdd:
Voici mon code (faux mdp bien sur):
<html>
<head>
<title>
</title>
</head>
<body>
<img style='position:absolute;' src='img/CACB-logo-generique-couleur.png'></img>
<center><h2>Statistiques Borne Signalez-Vous</h2></center><br><br>
<br><br>
<br><br><br>
<?php
// Paramètres pour accéder à ta base MysQl
$host = "nedim-accueil.fr";
$user = "nedim_ca";
$password = "cGMP8v3QfncsGWsL";
$bdd = "ca_tb_champbourg";
// Connection à ta Base MySql
mysql_connect($host, $user, $password) or die ("impossible de se connecter au serveur" );
mysql_select_db($bdd) or die ("impossible de se connecter a la base de donnees" );
// Ta requête (ta question)
$sql = "SELECT * FROM MessageAccueil WHERE month(DateCreationMessage)=month(now()) AND year(DateCreationMessage)=year(now()) AND IDAgence = 27";
$sql2 = "SELECT DISTINCT month(DateCreationMessage) FROM MessageAccueil WHERE month(DateCreationMessage)=month(now()) AND year(DateCreationMessage)=year(now()) AND IDAgence = 27";
// Son résultat (réponse à ta qestion)
$resultat=mysql_query($sql);
$resultat2=mysql_query($sql2);
// Eventuellement le nombre de réponse à ta question
$nombre_de_reponse=mysql_num_rows($resultat);
$nombre_de_reponse2=mysql_num_rows($resultat2);
while($ligne = mysql_fetch_array($resultat2))
{
if (@$ligne["month(DateCreationMessage)"] == 1)
$janvier = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 2)
$fevrier = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 3)
$mars = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 4)
$avril = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 5)
$mai = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 6)
$juin = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 7)
$juillet = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 8)
$aout = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 9)
$septembre = $nombre_de_reponse;
$fp = fopen('file.csv', 'w');
fputcsv($fp, $nombre_de_reponse);
fclose($fp);
if (@$ligne["month(DateCreationMessage)"] == 10)
$octobre = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 11)
$novembre = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 12)
$decembre = $nombre_de_reponse;
}
/* pChart library inclusions */
include("/class/pData.class.php");
include("/class/pDraw.class.php");
include("/class/pImage.class.php");
/* Create the pData object with some random values*/
$MyData = new pData();
$MyData->addPoints(array(@$janvier,@$fevrier,@$mars,@$avril,@$mai,@$juin,@$juillet,@$aout,@$septembre,@$octobre,@$novembre,@$decembre),"Dijon Darcy");
$MyData->addPoints(array("Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"),"Labels");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(1300,750,$MyData);
/* Create a solid background */
$Settings = array("R"=>255, "G"=>255, "B"=>255, "Dash"=>1, "DashR"=>199, "DashG"=>237, "DashB"=>111);
$myPicture->drawFilledRectangle(0,0,1300,750,$Settings);
/* Do a gradient overlay */
$Settings = array("StartR"=>255, "StartG"=>231, "StartB"=>255, "EndR"=>43, "EndG"=>107, "EndB"=>58, "Alpha"=>50);
$myPicture->drawGradientArea(0,0,1300,750,DIRECTION_VERTICAL,$Settings);
$myPicture->drawGradientArea(0,0,1300,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>100));
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,1299,749,array("R"=>0,"G"=>0,"B"=>0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>"fonts/Silkscreen.ttf","FontSize"=>8));
$myPicture->drawText(10,13,"Evolution du nombre d'appels via la borne",array("R"=>255,"G"=>255,"B"=>255));
/* Draw the scale */
$myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>16));
$myPicture->setGraphArea(50,60,1270,710);
$myPicture->drawFilledRectangle(50,60,1270,730,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("CycleBackground"=>TRUE));
/* Graph title */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->drawText(50,52,"Nombre d'appels",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Draw the bar chart chart */
$myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>12));
$MyData->setSerieDrawable("Last year",FALSE);
$myPicture->drawBarChart();
$myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>4,"Surrounding"=>-80,"BorderAlpha"=>90));
/* Draw the line and plot chart */
/* Make sure all series are drawable before writing the scale */
$MyData->setSerieDrawable("This year",TRUE);
/* Write the legend */
$myPicture->drawLegend(540,35,array("Style"=>LEGEND_ROUND,"Alpha"=>20,"Mode"=>LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->Render("img/example.combo.png");
?>
<center><img src="img/example.combo.png"></img></center>
A l'aide s'il vous plait ^^
Bonjour à tous,
Inutile de vous dire que je suis complètement desespéré je transpire le code tellement ça deviens compliqué pour moi !
Donc je vous explique je voudrais faire un outil de statistique qui irai chercher les infos dans une bdd (que je ne controle pas) et qui les afficherais sous forme de diagramme. L'affichage du diagramme fonctionne SAUF que mes valeurs sont fausse ou tout du moins elles sont bonne que pour le mois courant et mon diagramme n'affiche pas non plus les valeurs des mois derniers ! Ma requete doit etre fausse ensuite mon code n'est pas tres beau j'en suis conscient !
voici ma bdd:
[img]http://www.developpez.net/forums/attachments/p157479d1411999346/php/php-sgbd/php-mysql/statistiques-rapport-nombres-lignes-sql/titre.png/[/img]
Voici mon code (faux mdp bien sur):
[php]
<html>
<head>
<title>
</title>
</head>
<body>
<img style='position:absolute;' src='img/CACB-logo-generique-couleur.png'></img>
<center><h2>Statistiques Borne Signalez-Vous</h2></center><br><br>
<br><br>
<br><br><br>
<?php
// Paramètres pour accéder à ta base MysQl
$host = "nedim-accueil.fr";
$user = "nedim_ca";
$password = "cGMP8v3QfncsGWsL";
$bdd = "ca_tb_champbourg";
// Connection à ta Base MySql
mysql_connect($host, $user, $password) or die ("impossible de se connecter au serveur" );
mysql_select_db($bdd) or die ("impossible de se connecter a la base de donnees" );
// Ta requête (ta question)
$sql = "SELECT * FROM MessageAccueil WHERE month(DateCreationMessage)=month(now()) AND year(DateCreationMessage)=year(now()) AND IDAgence = 27";
$sql2 = "SELECT DISTINCT month(DateCreationMessage) FROM MessageAccueil WHERE month(DateCreationMessage)=month(now()) AND year(DateCreationMessage)=year(now()) AND IDAgence = 27";
// Son résultat (réponse à ta qestion)
$resultat=mysql_query($sql);
$resultat2=mysql_query($sql2);
// Eventuellement le nombre de réponse à ta question
$nombre_de_reponse=mysql_num_rows($resultat);
$nombre_de_reponse2=mysql_num_rows($resultat2);
while($ligne = mysql_fetch_array($resultat2))
{
if (@$ligne["month(DateCreationMessage)"] == 1)
$janvier = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 2)
$fevrier = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 3)
$mars = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 4)
$avril = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 5)
$mai = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 6)
$juin = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 7)
$juillet = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 8)
$aout = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 9)
$septembre = $nombre_de_reponse;
$fp = fopen('file.csv', 'w');
fputcsv($fp, $nombre_de_reponse);
fclose($fp);
if (@$ligne["month(DateCreationMessage)"] == 10)
$octobre = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 11)
$novembre = $nombre_de_reponse;
if (@$ligne["month(DateCreationMessage)"] == 12)
$decembre = $nombre_de_reponse;
}
/* pChart library inclusions */
include("/class/pData.class.php");
include("/class/pDraw.class.php");
include("/class/pImage.class.php");
/* Create the pData object with some random values*/
$MyData = new pData();
$MyData->addPoints(array(@$janvier,@$fevrier,@$mars,@$avril,@$mai,@$juin,@$juillet,@$aout,@$septembre,@$octobre,@$novembre,@$decembre),"Dijon Darcy");
$MyData->addPoints(array("Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"),"Labels");
$MyData->setAbscissa("Labels");
/* Create the pChart object */
$myPicture = new pImage(1300,750,$MyData);
/* Create a solid background */
$Settings = array("R"=>255, "G"=>255, "B"=>255, "Dash"=>1, "DashR"=>199, "DashG"=>237, "DashB"=>111);
$myPicture->drawFilledRectangle(0,0,1300,750,$Settings);
/* Do a gradient overlay */
$Settings = array("StartR"=>255, "StartG"=>231, "StartB"=>255, "EndR"=>43, "EndG"=>107, "EndB"=>58, "Alpha"=>50);
$myPicture->drawGradientArea(0,0,1300,750,DIRECTION_VERTICAL,$Settings);
$myPicture->drawGradientArea(0,0,1300,20,DIRECTION_VERTICAL,array("StartR"=>0,"StartG"=>0,"StartB"=>0,"EndR"=>50,"EndG"=>50,"EndB"=>50,"Alpha"=>100));
/* Add a border to the picture */
$myPicture->drawRectangle(0,0,1299,749,array("R"=>0,"G"=>0,"B"=>0));
/* Write the picture title */
$myPicture->setFontProperties(array("FontName"=>"fonts/Silkscreen.ttf","FontSize"=>8));
$myPicture->drawText(10,13,"Evolution du nombre d'appels via la borne",array("R"=>255,"G"=>255,"B"=>255));
/* Draw the scale */
$myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>16));
$myPicture->setGraphArea(50,60,1270,710);
$myPicture->drawFilledRectangle(50,60,1270,730,array("R"=>255,"G"=>255,"B"=>255,"Surrounding"=>-200,"Alpha"=>10));
$myPicture->drawScale(array("CycleBackground"=>TRUE));
/* Graph title */
$myPicture->setShadow(TRUE,array("X"=>1,"Y"=>1,"R"=>0,"G"=>0,"B"=>0,"Alpha"=>10));
$myPicture->drawText(50,52,"Nombre d'appels",array("FontSize"=>20,"Align"=>TEXT_ALIGN_BOTTOMLEFT));
/* Draw the bar chart chart */
$myPicture->setFontProperties(array("FontName"=>"fonts/Forgotte.ttf","FontSize"=>12));
$MyData->setSerieDrawable("Last year",FALSE);
$myPicture->drawBarChart();
$myPicture->drawPlotChart(array("DisplayValues"=>TRUE,"PlotBorder"=>TRUE,"BorderSize"=>4,"Surrounding"=>-80,"BorderAlpha"=>90));
/* Draw the line and plot chart */
/* Make sure all series are drawable before writing the scale */
$MyData->setSerieDrawable("This year",TRUE);
/* Write the legend */
$myPicture->drawLegend(540,35,array("Style"=>LEGEND_ROUND,"Alpha"=>20,"Mode"=>LEGEND_HORIZONTAL));
/* Render the picture (choose the best way) */
$myPicture->Render("img/example.combo.png");
?>
<center><img src="img/example.combo.png"></img></center>
[/php]
A l'aide s'il vous plait ^^