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

Langage PHP Discussion :

Jpgraphe ( gantt)/base de données


Sujet :

Langage PHP

  1. #1
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 12
    Points : 7
    Points
    7
    Par défaut Jpgraphe ( gantt)/base de données
    Bonjour,
    en effet je veux générer un diagramme de Gantt donc j'utilise jpgraphe.J'ai trouvé plusieurs exemples seulement je n'arrive pas a faire la liaison correcte avec ma base de donnée pour que la date début et la date fin ainsi les autres variables serons chargées directement depuis ma base de donnée donc voici mon code si vous pouvez m'aider je vous serais très reconnaissant
    merci .


    Code php : 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
    <?php 
    // content="text/plain; charset=utf-8" 
    // Gantt example 
    require_once ('src/jpgraph.php'); 
    require_once ('src/jpgraph_gantt.php'); 
     
    $graph = new GanttGraph(); 
     
    $graph->title->Set("Only month & year scale"); 
     
    // Setup some "very" nonstandard colors 
    $graph->SetMarginColor('lightgreen@0.8'); 
    $graph->SetBox(true,'yellow:0.6',2); 
    $graph->SetFrame(true,'darkgreen',4); 
    $graph->scale->divider->SetColor('yellow:0.6'); 
    $graph->scale->dividerh->SetColor('yellow:0.6'); 
     
    // Explicitely set the date range 
    // (Autoscaling will of course also work) 
    $graph->SetDateRange('2015-03-30','2016-4-10'); 
     
     
    // Display month and year scale with the gridlines 
    $graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR); 
    $graph->scale->month->grid->SetColor('gray'); 
    $graph->scale->month->grid->Show(true); 
    $graph->scale->year->grid->SetColor('gray'); 
    $graph->scale->year->grid->Show(true); 
     
     
    // Setup activity info 
     
    // For the titles we also add a minimum width of 100 pixels for the Task name column 
    $graph->scale->actinfo->SetColTitles( 
    array('Name','Duration','Start','Finish'),array(100)); 
    $graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5'); 
    $graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10); 
    $graph->scale->actinfo->vgrid->SetStyle('solid'); 
    $graph->scale->actinfo->vgrid->SetColor('gray'); 
     
    //connexion à la base de donnée 
    mysql_connect('localhost', 'root', ''); 
    mysql_select_db('gantt') ; 
     
    $requete=("SELECT nom , durée, date début, date fin FROM ga "); 
    $req=mysql_query($requete); 
    while($ligne=mysql_fetch_array($req)) 
    { 
     
    $name=$ligne[0]; 
    $duration=$ligne[1]; 
    $db=$ligne[2]; 
    $df=$ligne[3]; 
     
    // Data for our example activities 
    $data = array( 
    array(0,array("$name","$duration","$db","$df") 
    , "$db","$df",FF_ARIAL,FS_NORMAL,8), 
    ); 
    } 
    // Create the bars and add them to the gantt chart 
    for($i=0; $i<count($data); ++$i) { 
    $bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",10); 
    if( count($data[$i])>4 ) 
    $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]); 
    $bar->SetPattern(BAND_RDIAG,"yellow"); 
    $bar->SetFillColor("gray"); 
    $bar->progress->Set(0.5); 
    $bar->progress->SetPattern(GANTT_SOLID,"darkgreen"); 
    $graph->Add($bar); 
    } 
     
    // Output the chart 
    $graph->Stroke(); 
     
    ?>

  2. #2
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    j'ai fais une modification dans la construction de mon $data c'est de la que je pense viens l'erreur mais pareil il ne m'affiche pas le diagramme de gantt il m'affiche une icone gris des solutions à proposer svp je vous serais très reconnaissant.Voila le code actuel
    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
    <?php 
    // content="text/plain; charset=utf-8"
    // Gantt example
    require_once ('src/jpgraph.php');
    require_once ('src/jpgraph_gantt.php');
     
    $graph = new GanttGraph();
     
    $graph->title->Set("Only month & year scale");
     
    // Setup some "very" nonstandard colors
    $graph->SetMarginColor('lightgreen@0.8');
    $graph->SetBox(true,'yellow:0.6',2);
    $graph->SetFrame(true,'darkgreen',4);
    $graph->scale->divider->SetColor('yellow:0.6');
    $graph->scale->dividerh->SetColor('yellow:0.6');
     
    // Explicitely set the date range 
    // (Autoscaling will of course also work)
    $graph->SetDateRange('2015-03-30','2016-4-10');
     
     
    // Display month and year scale with the gridlines
    $graph->ShowHeaders(GANTT_HMONTH | GANTT_HYEAR);
    $graph->scale->month->grid->SetColor('gray');
    $graph->scale->month->grid->Show(true);
    $graph->scale->year->grid->SetColor('gray');
    $graph->scale->year->grid->Show(true);
     
     
    // Setup activity info
     
    // For the titles we also add a minimum width of 100 pixels for the Task name column
    $graph->scale->actinfo->SetColTitles(
        array('Name','Duration','Start','Finish'),array(100));
    $graph->scale->actinfo->SetBackgroundColor('green:0.5@0.5');
    $graph->scale->actinfo->SetFont(FF_ARIAL,FS_NORMAL,10);
    $graph->scale->actinfo->vgrid->SetStyle('solid');
    $graph->scale->actinfo->vgrid->SetColor('gray');
     
    //connexion à la base de donnée
    mysql_connect('localhost', 'root', '');
    mysql_select_db('gantt') ;
     
     $requete=("SELECT nom , durée, date début, date fin FROM ga ");
     $req=mysql_query($requete);
     
     $data = array();
     $x=0;
     while($ligne=mysql_fetch_array($req)){
     
     $name=$ligne[0];
     $duration=$ligne[1];
     $db=$ligne[2];
     $df=$ligne[3];
     
    // Data for our example activities
    $data[] = array($x ,array("$name","$duration","$db","$df") , "$db" ,"$df", FF_ARIAL,FS_NORMAL,8);
     $x++;
    }
     
    // Create the bars and add them to the gantt chart
    for($i=0; $i<count($data); ++$i) {
        $bar = new GanttBar($data[$i][0],$data[$i][1],$data[$i][2],$data[$i][3],"[50%]",10);
        if( count($data[$i])>4 )
            $bar->title->SetFont($data[$i][4],$data[$i][5],$data[$i][6]);
        $bar->SetPattern(BAND_RDIAG,"yellow");
        $bar->SetFillColor("gray");
        $bar->progress->Set(0.5);
        $bar->progress->SetPattern(GANTT_SOLID,"darkgreen");
        $graph->Add($bar);
    }
     
    // Output the chart
    $graph->Stroke();
     
     
    ?>

  3. #3
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Appelle directement ton script PHP pour voir l'erreur, éventuellement enlève la ligne d'output.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  4. #4
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    Bonjour sabotage ,
    j'ai enlevé le output par ailleurs il m'affiche cette erreur :
    Warning: mysql_fetch_array() expects parameter 1 to be resource, boolean given in C:\Program Files (x86)\EasyPHP-DevServer-14.1VC9\data\localweb\projects\jpgraph-3.5.0b1\gantt6.php on line 50
    c'est à dire dans cette ligne :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    while($ligne=mysql_fetch_array($req)){

  5. #5
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Cela signifie que ta requête n'est pas bonne, affiche les erreurs Mysql.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  6. #6
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    voici la requête que j'ai utilisé pour générer les erreurs mysql :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    $req=mysql_query($requete) or exit('Erreur SQL ligne '.__LINE__.' : '.mysql_error());
    et voici le msg d'erreur qui apparait :
    Erreur SQL ligne 46 : You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '©e, date début, date fin FROM ga' at line 1

  7. #7
    Modérateur
    Avatar de sabotage
    Homme Profil pro
    Inscrit en
    Juillet 2005
    Messages
    29 208
    Détails du profil
    Informations personnelles :
    Sexe : Homme

    Informations forums :
    Inscription : Juillet 2005
    Messages : 29 208
    Points : 44 155
    Points
    44 155
    Par défaut
    Ne met pas d'espace dans le nom de tes colonnes.
    N'oubliez pas de consulter les FAQ PHP et les cours et tutoriels PHP

  8. #8
    Futur Membre du Club
    Homme Profil pro
    Inscrit en
    Octobre 2011
    Messages
    12
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : Tunisie

    Informations forums :
    Inscription : Octobre 2011
    Messages : 12
    Points : 7
    Points
    7
    Par défaut
    oui sabotage exactement les espaces et les virgules et sa marche à merveille merci beaucoup pour ton aide claire et précise

+ Répondre à la discussion
Cette discussion est résolue.

Discussions similaires

  1. diagramme de gantt/base de données
    Par challenger11 dans le forum Langage
    Réponses: 1
    Dernier message: 31/07/2015, 17h20
  2. [JPgraph] Problème avec la connexion de la base de données
    Par infooo dans le forum Bibliothèques et frameworks
    Réponses: 1
    Dernier message: 15/03/2014, 20h08
  3. [JpGraph] faire un graph a partir d'une base de données sous jpgraph!
    Par wookie33 dans le forum Bibliothèques et frameworks
    Réponses: 3
    Dernier message: 23/05/2012, 11h51
  4. [Concept] Stabilité d'une base de donnée
    Par lassmust dans le forum Décisions SGBD
    Réponses: 3
    Dernier message: 03/07/2002, 17h16
  5. associer une base de données(access) a un dbgrid
    Par ange1708 dans le forum MFC
    Réponses: 3
    Dernier message: 11/06/2002, 13h18

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