Précédent   Forum des professionnels en informatique > PHP > PHP & SGBD > PHP & MySQL
PHP & MySQL Forum d'entraide sur les fonctions MySQL avec PHP. Avant de poster -> FAQ MySQL, Cours MySQL et Sources MySQL. Pour les questions concernant le moteur MySQL plutôt que les fonctions PHP, merci d'utiliser le forum MySQL.
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse Proposer ce sujet en actualité
 
Outils de la discussion
Publicité
'
Vieux 17/05/2011, 18h48   #1
Invité de passage
 
Homme samir
Inscription : mai 2011
Messages : 6
Détails du profil
Informations personnelles :
Nom : Homme samir

Informations forums :
Inscription : mai 2011
Messages : 6
Points : 0
Points : 0
Par défaut problème d'affichage d'un graphique en php sur ma page html

Bonjour,

je souhaite afficher un graphique en bâton(codé en php)sur une page html mais ça ne marche pas.

En fait j'ai une page php poour la création du graphique et une page html pour afficher le graphique.

voici ci-dessous mes fichiers

graphique.php
Code :
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
require_once('Artichow/BarPlot.class.php');
//Connexion au serveur MySQL
		$db=mysql_connect("localhost","v_util","vpc@2006") or die ("erreur de connexion".mysql_error());
//ouverture de la base bac
		mysql_select_db("bac",$db)or die("erreur de connexion à la base ");
//tableau de resultat
$annee = array();
$pourcentage = array(); 
$sql = "SELECT annee, pourcentage FROM resultat"   or die('req invalide');
$req = mysql_query($sql);
while($result = mysql_fetch_array($req)){
array_push($pourcentage, $result[0]);
array_push($annee, $result[1]);
} 
//creation du graphique : batons
$graph = new Graph(500,500);
$graph->setAntiAliasing(TRUE);
 
//Creation du LinePlot
$plot = new BarPlot($annee);
 
//ajoute une couleur de fond aux barres
$plot->setBarColor(
      new Color(255, 250, 250)
   );
//On un ajoute un titre
$plot->title->set("Résultats du BAC STG GSI");
$plot->title->setFont(new TuffyBold(11));
$plot->title->border->show();
$plot->title->setBackgroundColor(new Color(255, 255, 255, 25));
$plot->title->setPadding(4, 4, 4, 4);
$plot->title->move(-20, 25);
// Ajout du titre de l'axe des Y
$plot->yAxis->title->set("Pourcentage");
$plot->yAxis->title->setFont(new TuffyBold(10));
$plot->yAxis->title->move(-4, 0);
$plot->yAxis->setTitleAlignment(Label::TOP);
//Ajout du titre de l'axe des X
$plot->xAxis->title->set("Année");
$plot->xAxis->title->setFont(new TuffyBold(10));
$plot->xAxis->setTitleAlignment(Label::RIGHT);
 
// On ajoute 5 % d'espace à gauche et à droite de l'histogramme.
   // On ne change pas l'espace du haut et du bas de l'histogramme.
$plot->setSpace(
      5, /* Gauche */
      5, /* Droite */
      NULL, /* Haut */
      NULL /* Bas */
   );
 
// On choisit une ombre de 3 pixels
$plot->barShadow->setSize(3);
   // On place l'ombre sur les côtés haut et droit.
   // Si vous utilisez Artichow pour PHP 4 & 5, transformez Shadow::RIGHT_TOP en 	SHADOW_RIGHT_TOP
$plot->barShadow->setPosition(Shadow::RIGHT_TOP);
   // On veut une ombre de couleur grise
$plot->barShadow->setColor(new Color(256, 180, 180, 10));
   // On choisit de lisser les extrémités de l'ombre
$plot->barShadow->smooth(TRUE);
//Affichage des noms sur l'axe X
$plot->xAxis->setLabelText($pourcentage);
//Affichage du graphe
$graph->add($plot); 
$graph->draw();
// fermer la connexion à la base
 		 mysql_close($db);
?>

Résultat.html
Code html :
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
<html>
<head>
<title>
Lycee Daniel Dumand
</title>
</head>
<link rel="stylesheet" type="text/css" href="AC.css" /> 
<body>
 
 
 
<div id="lien">
<table>
<tr>
<td><a href="Acceuil.html"> Accueil </a></td>
<td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td>|
<td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td>
<td><a href="metier.html"> Metiers </a></td>
<td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td>|
<td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td>
<td><a href="deboucher.html"> Debouchés </a></td>
<td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td><td>|
<td><td><td><td><td><td><td><td><td><td><td><td><td><td><td>
<td><a href="resultat.html"> Resultats </a></td>
</table>
</div>
 
<div id="centre">
 
<center><img src="rr.jpg"></center>
 
<center>
</br>
<p><h5><font color="#5a5a00">&nbsp;Ces résultats montre le taux de reussite en pourcentage de la série STG GSI entre 2006 et 2010.</font></p></br></h5>
</center>
 
<center><img src="graphique.php"></center>
</div>
<center><h5><p>Source : Secretariat du lycée Daniel Dumand </p></h5></center>
 
 
 
 
<div id="img3">
<img src="hobbie-dessin.gif">
</div>
 
</body>
</html>
Auriez vous une idée pourquoi ça ne marche pas?

Cordialement
sbenamor est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/05/2011, 19h54   #2
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 270
Points : 7 270
Bonsoir,

Essaye d'appeler directement la page php et commente la ligne
Citation:
$graph->draw();
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/05/2011, 19h57   #3
Expert Confirmé
 
Avatar de Séb.
 
Inscription : mars 2005
Messages : 2 823
Détails du profil
Informations personnelles :
Âge : 34
Localisation : France

Informations professionnelles :
Secteur : High Tech - Opérateur de télécommunications

Informations forums :
Inscription : mars 2005
Messages : 2 823
Points : 3 449
Points : 3 449
Citation:
Auriez vous une idée pourquoi ça ne marche pas?
Non.

Accède directement à la "page" graphique.php pour voir s'il n'y a pas des erreurs.

Edit : grilled
__________________
Un problème exposé clairement est déjà à moitié résolu
Keep It Smart and Simple
Séb. est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 17/05/2011, 20h00   #4
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 270
Points : 7 270
Euh
Citation:
$sql = "SELECT annee, pourcentage FROM resultat" or die('req invalide');
$req = mysql_query($sql);
Code :
1
2
$sql = "SELECT annee, pourcentage FROM resultat"; 
$req = mysql_query($sql) or die('req invalide') ;
A+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/05/2011, 15h41   #5
Invité de passage
 
Homme samir
Inscription : mai 2011
Messages : 6
Détails du profil
Informations personnelles :
Nom : Homme samir

Informations forums :
Inscription : mai 2011
Messages : 6
Points : 0
Points : 0
Par défaut problème d'affichage d'un graphique en php sur ma page html Répondre à la discussion

Bonjour,

Merci beaucoup de m'avoir répondu,
Voici l'erreur qu'on m'indique sur la page php concernant le graphique:

Citation:
Warning: require_once(Artichow/BarPlot.class.php) [function.require-once]: failed to open stream: No such file or directory in C:\Program Files\EasyPHP5.3.0\www\site\graphique.php on line 2

Fatal error: require_once() [function.require]: Failed opening required 'Artichow/BarPlot.class.php' (include_path='.;C:\php5\pear') in C:\Program Files\EasyPHP5.3.0\www\site\graphique.php on line 2
Auriez-vous une idée?

Très cordialement
sbenamor est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/05/2011, 15h46   #6
Membre éprouvé
 
Avatar de Nheo_
 
Homme
Étudiant
Inscription : avril 2011
Messages : 317
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations professionnelles :
Activité : Étudiant

Informations forums :
Inscription : avril 2011
Messages : 317
Points : 405
Points : 405
Bonjour,

L'erreur indique que ton script ne peut pas ouvrir BarPlot.class.php, vérifie le chemin vers le fichier.
Nheo_ est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 18/05/2011, 15h47   #7
Rédacteur/Modérateur
 
Avatar de andry.aime
 
Homme Andry Aimé
Inscription : septembre 2007
Messages : 5 128
Détails du profil
Informations personnelles :
Nom : Homme Andry Aimé
Localisation : Ile Maurice

Informations forums :
Inscription : septembre 2007
Messages : 5 128
Points : 7 270
Points : 7 270
Re,

Citation:
require_once('Artichow/BarPlot.class.php');
essaie de remplacer par
Code :
require_once('./Artichow/BarPlot.class.php');
le dossier Artichow est dans le même répertoire que graphique.php?
Le fichier BarPlot.class.php existe-t-il dans le dossier Artichow ?
Essaie de respecter la case si tu n'es pas sous windows.

A+.
andry.aime est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 24/05/2011, 17h00   #8
Invité de passage
 
Homme samir
Inscription : mai 2011
Messages : 6
Détails du profil
Informations personnelles :
Nom : Homme samir

Informations forums :
Inscription : mai 2011
Messages : 6
Points : 0
Points : 0
Merci beaucoup, ça marche

Très cordialement
sbenamor est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse Proposer ce sujet en actualité Cette discussion est résolue.
Outils de la discussion



Fuseau horaire GMT +2. Il est actuellement 13h54.


 
 
 
 
Partenaires

Hébergement Web