IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

PHP & Base de données Discussion :

Problème avec Jpgraph+PHP+Mysql [MySQL]


Sujet :

PHP & Base de données

  1. #1
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut Problème avec Jpgraph+PHP+Mysql
    Bonjour à tous,

    Alors voila, j'ai créer un formulaire qui récupère le mois et l'année dans ma base Mysql pour récupérer les données sélectionnées et faire apparaitre un camembert en conséquence.

    Le soucis s'est que le camembert ne s'affiche pas alors que quand j'essaye mais sans le formulaire ça passe .

    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    <?php
    include ("../jpGraph/jpgraph.php");
    include ("../jpGraph/jpgraph_pie.php");
     
     
    define('MYSQL_HOST', 'localhost');
    define('MYSQL_USER', 'root');
    define('MYSQL_PASS', '');
    define('MYSQL_DATABASE', 'glpi');
     
    ?>
    <form method="post">
    <select name="mois"> 
    <?php
     
     
      // Récupération des informations triées par ordre alphabétique 
    $sql = 'SELECT MONTH(date) as mois FROM glpi_excel GROUP BY MONTH(date)';
                    // Connexion à la BDD
    $mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');
     
    // Sélection de la base de données
    @mysql_select_db(MYSQL_DATABASE) or die('Pb de sélection de la base');
     
    // Requête
    $mysqlQuery = @mysql_query($sql, $mysqlCnx) or die('Pb de requête');
                    while($data = mysql_fetch_array($mysqlQuery)){
                        // on affiche chaque champ
                        echo '<option name="'.$data['mois'].'">'.$data['mois'].'</option>';
                    }
                    //On libère mysql de cette première requête
                    mysql_free_result ($req); 
                    //On ferme le select
    ?>
    </SELECT>
     
    <select name="annee"> 
    <?php
     
     
      // Récupération des informations triées par ordre alphabétique 
    $sql = 'SELECT YEAR(date) as annee FROM glpi_excel GROUP BY YEAR(date)';
     // Connexion à la BDD
    $mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');
     
    // Sélection de la base de données
    @mysql_select_db(MYSQL_DATABASE) or die('Pb de sélection de la base');
     
    // Requête
    $mysqlQuery = @mysql_query($sql, $mysqlCnx) or die('Pb de requête');
                    while($data = mysql_fetch_array($mysqlQuery)){
                        // on affiche chaque champ
                        echo '<option name="'.$data['annee'].'">'.$data['annee'].'</option>';
                    }
                    //On libère mysql de cette première requête
                    mysql_free_result ($req); 
                    //On ferme le select
    ?>
     
    <input type="submit" name="Valider" value="OK"/>
    </SELECT>
    </form>         
     
    <?php
     
    // Tableaux de données destinées à JpGraph
    $tableaucategorie = array();
    $tableauouvert = array();
     
            //On traite le formulaire
            if(isset($_POST['Valider'])){
                $mois=$_POST['mois'];
                $annee=$_POST['annee'];
     
    			$sql =
    		'SELECT  
    		name AS categorie,
    		COUNT(ID) AS ouvert  
    	FROM glpi_excel
    	WHERE YEAR(date) = '.$annee.' AND MONTH(date) = '.$mois.'
    	GROUP BY name'
     
    ;
     
    // Connexion à la BDD
    $mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');
     
    // Sélection de la base de données
    @mysql_select_db(MYSQL_DATABASE) or die('Pb de sélection de la base');
     
    // Requête
    $mysqlQuery = @mysql_query($sql, $mysqlCnx) or die('Pb de requête');
     
    // Fetch sur chaque enregistrement
    while ($row = mysql_fetch_array($mysqlQuery,  MYSQL_ASSOC)) {
    	// Alimentation des tableaux de données
    	$tableaucategorie[] = $row['categorie'];
    	$tableauouvert[] = $row['ouvert'];
     
    	//print_r($tableaucategorie);
    }
     
     
    // ********************************************************************
    // PARTIE : Création du graphique 
    // ********************************************************************
     
    // On spécifie la largeur et la hauteur du graphique conteneur 
    $graph = new PieGraph(800,600);
     
    // Titre du graphique
    $graph->title->Set("Nombre de tickets ouverts");
     
    // Créer un graphique secteur (classe PiePlot)
    $oPie = new PiePlot($tableauouvert);
     
    // Légendes qui accompagnent chaque secteur, ici chaque année
    $oPie->SetLegends($tableaucategorie);
     
    // position du graphique (légèrement à droite)
    $oPie->SetCenter(0.3); 
     
    $oPie->SetValueType(PIE_VALUE_ABS);
     
    // Format des valeurs de type entier
    $oPie->value->SetFormat('%d');
     
     
    // Ajouter au graphique le graphique secteur
    $graph->Add($oPie);
     
    // Provoquer l'affichage (renvoie directement l'image au navigateur)
    $graph->Stroke();
    }
    ?>
    Merci à ceux qui pourront m'aider, je mets en PJ la BDD que j'utilise pour mes tests.
    Fichiers attachés Fichiers attachés

  2. #2
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    le résultat de tes requêtes est bon !!!!!?

  3. #3
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par redoran Voir le message
    le résultat de tes requêtes est bon !!!!!?
    Oui déjà vérifier cela aussi, les informations remontent sans soucis.
    Même je suis allé plus loin, j'ai testé sans le menu déroulant en mettant moi même une année et un mois dans la requête et ça passe...

    Donc je coince toujours ><

  4. #4
    Membre expert
    Avatar de ericd69
    Homme Profil pro
    Développeur informatique
    Inscrit en
    Avril 2011
    Messages
    1 919
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Isère (Rhône Alpes)

    Informations professionnelles :
    Activité : Développeur informatique
    Secteur : High Tech - Multimédia et Internet

    Informations forums :
    Inscription : Avril 2011
    Messages : 1 919
    Points : 3 295
    Points
    3 295
    Billets dans le blog
    1
    Par défaut
    tu as un <input>

    qui traine dans le <select> de ton formulaire année

  5. #5
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par ericd69 Voir le message
    tu as un <input>

    qui traine dans le <select> de ton formulaire année
    Ba oui je sais c'est normal, sa me permet de valider la sélection que je fais dans le menu déroulant.

  6. #6
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    le input signalé par ericd69 doit étre en dehors du select , ensuite tu peut valider comme tu veux , alors fait le ressortir Ok.
    maintenant si ta requête est bonne , je te donne un lien avec jpagraph pour t’inspirai.
    http://www.developpez.net/forums/d12...e/#post6720459

    sinon merci les modérateur pour transféré le post vers la rubrique jpgraph.

  7. #7
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par redoran Voir le message
    le input signalé par ericd69 doit étre en dehors du select , ensuite tu peut valider comme tu veux , alors fait le ressortir Ok.
    maintenant si ta requête est bonne , je te donne un lien avec jpagraph pour t’inspirai.
    http://www.developpez.net/forums/d12...e/#post6720459

    sinon merci les modérateur pour transféré le post vers la rubrique jpgraph.
    Aah d'accord.Merci pour la note et pour le lien je vais voir si ça peut m'aider.

  8. #8
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031

  9. #9
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    Le soucis s'est que le camembert ne s'affiche pas alors que quand j'essaye mais sans le formulaire ça passe .
    ici vous avez un affichage des secteurs avec des données non issues de la requête.

    sinon essaye avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    .......
    // Créer un graphique secteur (classe PiePlot)
    $oPie = new PiePlot($tavariable);
    // Ajouter au graphique le graphique secteur
    $graph->Add($oPie);
    ......
    c'est un bug , j'ai eu le même problème avec les courbes.

  10. #10
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par redoran Voir le message
    ici vous avez un affichage des secteurs avec des données non issues de la requête.

    sinon essaye avec :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    .......
    // Créer un graphique secteur (classe PiePlot)
    $oPie = new PiePlot($tavariable);
    // Ajouter au graphique le graphique secteur
    $graph->Add($oPie);
    ......
    c'est un bug , j'ai eu le même problème avec les courbes.
    Ok...mais désolé mais je dois mettre quoi dans $oPie = new PiePlot($tavariable); ??

    J'ai déjà une variable $tableauouvert de rentrer...
    Et oui je suis déjà aller sur le tuto de Jpgraph s'est même à partir de sa que j'ai effectué mon graph.^^

  11. #11
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    $tableaucategorie[] = $row['categorie'];
    $tableauouvert[] = $row['ouvert'];
    essaye de faire un var_dump de tes deux variables ?

  12. #12
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par redoran Voir le message
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
     
    $tableaucategorie[] = $row['categorie'];
    $tableauouvert[] = $row['ouvert'];
    essaye de faire un var_dump de tes deux variables ?
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    104
    105
    106
    107
    108
    109
    110
    111
    112
    113
    114
    115
    116
    117
    118
    119
    120
    121
    122
    123
    124
    125
    126
    127
    128
    129
    130
    131
    132
    133
    134
    135
    136
    137
    138
    139
    140
    141
    142
    143
    144
    145
    146
    147
    148
    149
    150
    151
    152
    153
    154
    155
    156
    157
    158
    159
    160
    161
    162
    163
    164
    165
    166
    167
    168
    169
    170
    171
    172
    173
    174
    175
    176
    177
    178
    179
    180
    181
    182
    183
    184
    185
    186
    187
    188
    189
    190
    191
    192
    193
    194
    195
    196
    197
    198
    199
    200
    201
    202
    203
    204
    205
    206
    207
    208
    209
    210
    211
    212
    213
    214
    215
    216
    217
    218
    219
    220
    221
    222
    223
    224
    225
    226
    227
    228
    229
    230
    231
    232
    233
    array (size=1)
      0 => string 'AS400' (length=5)
     
    array (size=1)
      0 => string '6' (length=1)
     
    array (size=2)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
     
    array (size=2)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
     
    array (size=3)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
     
    array (size=3)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
     
    array (size=4)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
     
    array (size=4)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
     
    array (size=5)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
     
    array (size=5)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
     
    array (size=6)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
     
    array (size=6)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
     
    array (size=7)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
      6 => string 'GAB' (length=3)
     
    array (size=7)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
      6 => string '4' (length=1)
     
    array (size=8)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
      6 => string 'GAB' (length=3)
      7 => string 'Idom' (length=4)
     
    array (size=8)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
      6 => string '4' (length=1)
      7 => string '1' (length=1)
     
    array (size=9)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
      6 => string 'GAB' (length=3)
      7 => string 'Idom' (length=4)
      8 => string 'Impression' (length=10)
     
    array (size=9)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
      6 => string '4' (length=1)
      7 => string '1' (length=1)
      8 => string '23' (length=2)
     
    array (size=10)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
      6 => string 'GAB' (length=3)
      7 => string 'Idom' (length=4)
      8 => string 'Impression' (length=10)
      9 => string 'Messagerie' (length=10)
     
    array (size=10)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
      6 => string '4' (length=1)
      7 => string '1' (length=1)
      8 => string '23' (length=2)
      9 => string '5' (length=1)
     
    array (size=11)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
      6 => string 'GAB' (length=3)
      7 => string 'Idom' (length=4)
      8 => string 'Impression' (length=10)
      9 => string 'Messagerie' (length=10)
      10 => string 'Mot de passe' (length=12)
     
    array (size=11)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
      6 => string '4' (length=1)
      7 => string '1' (length=1)
      8 => string '23' (length=2)
      9 => string '5' (length=1)
      10 => string '7' (length=1)
     
    array (size=12)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
      6 => string 'GAB' (length=3)
      7 => string 'Idom' (length=4)
      8 => string 'Impression' (length=10)
      9 => string 'Messagerie' (length=10)
      10 => string 'Mot de passe' (length=12)
      11 => string 'Reseau' (length=6)
     
    array (size=12)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
      6 => string '4' (length=1)
      7 => string '1' (length=1)
      8 => string '23' (length=2)
      9 => string '5' (length=1)
      10 => string '7' (length=1)
      11 => string '6' (length=1)
     
    array (size=13)
      0 => string 'AS400' (length=5)
      1 => string 'Bureautique' (length=11)
      2 => string 'Changement de poste de travail' (length=30)
      3 => string 'Coupure reseau' (length=14)
      4 => string 'Equant' (length=6)
      5 => string 'Exploitation' (length=12)
      6 => string 'GAB' (length=3)
      7 => string 'Idom' (length=4)
      8 => string 'Impression' (length=10)
      9 => string 'Messagerie' (length=10)
      10 => string 'Mot de passe' (length=12)
      11 => string 'Reseau' (length=6)
      12 => string 'Session Citrix' (length=14)
     
    array (size=13)
      0 => string '6' (length=1)
      1 => string '17' (length=2)
      2 => string '1' (length=1)
      3 => string '5' (length=1)
      4 => string '2' (length=1)
      5 => string '9' (length=1)
      6 => string '4' (length=1)
      7 => string '1' (length=1)
      8 => string '23' (length=2)
      9 => string '5' (length=1)
      10 => string '7' (length=1)
      11 => string '6' (length=1)
      12 => string '30' (length=2)
    Voici ce que j'ai en faisant un var_dump des 2 variables.
    Pour moi il n'y a rien de bizarre ou te particulier...

  13. #13
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    sincèrement j'arrive pas a faire lle lien entre le résultat du var_dump et la réalisation du graphe. !!!
    normalement tu doit avoir par exemple:
    chiffre d'affaire par année,
    volume de vente par année,
    .......
    donc dans le résultat c'est pas clair , normalement tu doit avoir un regroupement par mois non !!!!
    donne un jeux de résultat attendu de la requête.

  14. #14
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par redoran Voir le message
    sincèrement j'arrive pas a faire lle lien entre le résultat du var_dump et la réalisation du graphe. !!!
    normalement tu doit avoir par exemple:
    chiffre d'affaire par année,
    volume de vente par année,
    .......
    donc dans le résultat c'est pas clair , normalement tu doit avoir un regroupement par mois non !!!!
    donne un jeux de résultat attendu de la requête.
    Ba en faite le résultat final est un camembert qui récupère pour par exemple le mois de Mai tout les tickets d'incident ouvert par catégorie et enregistré dans la BDD.

    On a plusieurs catégories(imprimante,as400,réseau,...).
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    <?php
     
    include ("../jpGraph/jpgraph.php");
    include ("../jpGraph/jpgraph_pie.php");
     
     
    define('MYSQL_HOST', 'localhost');
    define('MYSQL_USER', 'root');
    define('MYSQL_PASS', '');
    define('MYSQL_DATABASE', 'glpi');	
     
     
    // Tableaux de données destinées à JpGraph
    $tableaucategorie = array();
    $tableauouvert = array();
     
    // ********************************************************************
    // PARTIE : Production des données avec Mysql
    // ********************************************************************
     
    $sql = '
    	SELECT  
    		name AS categorie,
    		COUNT(ID) AS ouvert  
    	FROM `glpi_excel`
    	WHERE YEAR(date) = 2012 AND MONTH(date) = 6
    	GROUP BY name'
     
    ;
     
    // Connexion à la BDD
    $mysqlCnx = @mysql_connect(MYSQL_HOST, MYSQL_USER, MYSQL_PASS) or die('Pb de connxion mysql');
     
    // Sélection de la base de données
    @mysql_select_db(MYSQL_DATABASE) or die('Pb de sélection de la base');
     
    // Requête
    $mysqlQuery = @mysql_query($sql, $mysqlCnx) or die('Pb de requête');
     
    // Fetch sur chaque enregistrement
    while ($row = mysql_fetch_array($mysqlQuery,  MYSQL_ASSOC)) {
    	// Alimentation des tableaux de données
    	$tableaucategorie[] = $row['categorie'];
    	$tableauouvert[] = $row['ouvert'];
     
    	//print_r($tableaucategorie);
    	//print_r($tableauouvert);
    }
     
    // ********************************************************************
    // PARTIE : Création du graphique 
    // ********************************************************************
     
    // On spécifie la largeur et la hauteur du graphique conteneur 
    $graph = new PieGraph(800,600);
     
    // Titre du graphique
    $graph->title->Set("Nombre de tickets ouverts");
     
    // Créer un graphique secteur (classe PiePlot)
    $oPie = new PiePlot($tableauouvert);
     
    // Légendes qui accompagnent chaque secteur, ici chaque année
    $oPie->SetLegends($tableaucategorie);
     
    // position du graphique (légèrement à droite)
    $oPie->SetCenter(0.3); 
     
    $oPie->SetValueType(PIE_VALUE_ABS);
     
    // Format des valeurs de type entier
    $oPie->value->SetFormat('%d');
     
     
    // Ajouter au graphique le graphique secteur
    $graph->Add($oPie);
     
    // Provoquer l'affichage (renvoie directement l'image au navigateur)
    $graph->Stroke();
     
    ?>
    Voici le code qui fait sortir le graph sans soucis mais sans la partie liste déroulante.(la sauvegarde de la bdd est tout en haut si tu veut voir)

    Je mets en PJ le résultat graphique.
    Images attachées Images attachées  

  15. #15
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    le var_dump des variables $mois $annee donne quoi comme résultat? question de voir le contenu transféré avec $_POST

  16. #16
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par redoran Voir le message
    le var_dump des variables $mois $annee donne quoi comme résultat? question de voir le contenu transféré avec $_POST
    Alors voilà ce que j'obtiens pour le $mois et $annee
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
     
    string '4' (length=1)
     
    string '2012' (length=4)
    Pour $_POST j'ai :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    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
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
     
    array (size=3)
      'mois' => string '4' (length=1)
      'annee' => string '2012' (length=4)
      'Valider' => string 'OK' (length=2)
    En espérant que ça puisse t'aider.

  17. #17
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Information en plus,j'ai fait un var_dump des variables $tableauouvert,$tableaucategorie et $ sql sur le code php que j'ai faite sans la liste déroulante pour comparer ce que j'ai comme info avec et sans la liste déroulante.
    C'est exactement pareil...
    Je commence à désespérer

  18. #18
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    le var_dump des variables $mois $annee donne quoi comme résultat? question de voir le contenu transféré avec $_POST
    Normalement tu doit avoir un seul mois est une année pour les paramètres
    exemple mois 4 , année 2011. c'est des valeurs issue des balises select non !!!!

    ensuite tu les utilisent dans la requête.

  19. #19
    Nouveau membre du Club
    Homme Profil pro
    Administrateur systèmes et réseaux
    Inscrit en
    Mai 2011
    Messages
    65
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Dom-Tom

    Informations professionnelles :
    Activité : Administrateur systèmes et réseaux
    Secteur : Finance

    Informations forums :
    Inscription : Mai 2011
    Messages : 65
    Points : 39
    Points
    39
    Par défaut
    Citation Envoyé par redoran Voir le message
    Normalement tu doit avoir un seul mois est une année pour les paramètres
    exemple mois 4 , année 2011. c'est des valeurs issue des balises select non !!!!

    ensuite tu les utilisent dans la requête.
    J'ai mis plus haut(#16) ce que j'obtiens en faisant un var_dump de $mois et $annee quand je sélectionne le mois 4 et l'année 2012.

  20. #20
    Membre éprouvé Avatar de redoran
    Homme Profil pro
    Développeur-Amateur
    Inscrit en
    Juin 2010
    Messages
    1 346
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Âge : 52
    Localisation : Algérie

    Informations professionnelles :
    Activité : Développeur-Amateur
    Secteur : Santé

    Informations forums :
    Inscription : Juin 2010
    Messages : 1 346
    Points : 1 031
    Points
    1 031
    Par défaut
    résumant:
    ta requête accepte deux paramètres mois et année:
    $mois=$_POST['mois'];
    $annee=$_POST['annee'];

    la variable $mois récupère bien sa valeur exemple 4
    la variable $annee récupère bien sa valeur exemple 2012.

    en lisant message #3
    Même je suis allé plus loin, j'ai testé sans le menu déroulant en mettant moi même une année et un mois dans la requête et ça passe...
    le problème vient du $_POST[] !!!!!

    as-tu fait ressortir le input du select ?:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
     
    <select>
    .......
    ton code
    .....
    </SELECT>
    <input type="submit" name="Valider" value="OK"/>
    ensuite tu confirme l'hypothèse:
    Voici le code qui fait sortir le graph sans soucis mais sans la partie liste déroulante.(la sauvegarde de la bdd est tout en haut si tu veut voir)
    le var_dump des variables $mois $annee donne quoi comme résultat? question de voir le contenu transféré avec $_POST
    normalement sa donne
    $annee=2012 , $mois=4 et non cette liste citée dans le message #16.

    le résultat final doit être par exemple:
    tableau 1 : (AS400,Blade,Bureautique........)
    tableau 2: (20,25,30,5..........).
    c'est cette forme qui te permet de construire le graphe.

+ Répondre à la discussion
Cette discussion est résolue.
Page 1 sur 2 12 DernièreDernière

Discussions similaires

  1. [MySQL] Problème avec connection multiple mysql et fonction php
    Par mitchb dans le forum PHP & Base de données
    Réponses: 2
    Dernier message: 07/08/2009, 11h41
  2. Problème avec Flash + PHP/MySQL
    Par wylls dans le forum Flash
    Réponses: 12
    Dernier message: 04/01/2007, 12h23
  3. pb avec quote...php + mysql
    Par nicdes dans le forum SQL Procédural
    Réponses: 7
    Dernier message: 10/12/2005, 01h25
  4. Problèmes avec INTERSECT sur MYSQL
    Par zarbydigital dans le forum Requêtes
    Réponses: 1
    Dernier message: 27/09/2005, 13h18
  5. Problème avec mon service mysql et PhpMyAdmin
    Par Fixazo dans le forum Outils
    Réponses: 1
    Dernier message: 28/08/2005, 18h02

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo