谷歌图表代表

时间:2017-02-20 17:33:12

标签: php charts

好的,所以我的计划是动态关联我的表单数据并将其绘制在谷歌图表上...... 我的表单将有3个单独的组合列 我的计划是从数据库中获取员工的位置并取平均值并在图表上表示......

Namely Intern-avg Feedback-1 combo(Including Attributes)chart
Employee-avg Feedback-1 combo(Including Attributes)chart
Team Leader-avg Feedback-1 combo(Including Attributes)chart

这是我的档案

 <html>
  <head>
  <?php 
 if(!empty('$_SESSION'))
  {
    $conn = mysql_connect("localhost", "root", "");
    mysql_select_db('lothlorien');
    session_start();

if (!$conn) {
    echo "Error: Unable to connect to MySQL." . PHP_EOL;
    echo "Debugging errno: " . mysqli_connect_errno() . PHP_EOL;
    echo "Debugging error: " . mysqli_connect_error() . PHP_EOL;
    exit;
}
    $query1="SELECT `Productiveness`,`Work_Exp`,`Auth`,`Not_Biased`,`Emp_Name`,`Position` FROM `lothlorien`.`feedback`";
    $result1 = mysql_query($query1,$conn);

  }
  else
  {
    echo"Problem in Fetching...";
  }

  ?>
    <script type="text/javascript" src="https://www.gstatic.com/charts/loader.js"></script>
    <script type="text/javascript">
      google.charts.load('current', {'packages':['corechart']});
      google.charts.setOnLoadCallback(drawVisualization);


      function drawVisualization() {
        // Some raw data (not necessarily accurate)
        <?php 
        if(mysql_num_rows($result1)>0)
        {
          $index = 0;
          $total1= 0;
          $total2 = 0;
          $total3= 0;
          $total4= 0;
          ?>

              var data = google.visualization.arrayToDataTable([
                 ['Index', 'Productiveness', 'Work Experience', 'Authority/Discipline', 'Racist/Biased', 'Average'],

                      <?php
                          while($fetch1=mysql_fetch_assoc($result1))
                          {

                            $C_1=$fetch1['Productiveness'];
                            $C_2=$fetch1['Work_Exp'];
                            $C_3=$fetch1['Auth'];
                            $C_4=$fetch1['Not_Biased'];
                            $C_5=$fetch1['Emp_Name'];
                            $C_6=$fetch1['Position'];
                            if($C_6=='Intern')
                            {

                                $store1=$C_1;
                                $total1=$store1+$total1;
                                $avg1=$total1/$index+1;
                                echo $avg1;
                                $store2=$C_2;
                                $total2=$store2+$total2;
                                $avg2=$total2/$index+1;
                                echo $avg2;
                                $store3=$C_3;
                                $total3=$store3+$total3;
                                $avg3=$total3/$index+1;
                                echo $avg3;
                                $store4=$C_4;
                                $total4=$store4+$total4;
                                $avg4=$total4/$index+1;
                                echo $avg4;
                                $index++;
                            }
                            else if($C_6=='Employee')
                            {
                                $store11=$C_1;
                                $total11=$store11+$total11;
                                $avg11=$total11/$index+1;
                                echo $avg11;
                                $store12=$C_2;
                                $total12=$store2+$total2;
                                $avg12=$total2/$index+1;
                                echo $avg12;
                                $store13=$C_3;
                                $total13=$store13+$total13;
                                $avg13=$total13/$index+1;
                                echo $avg13;
                                $store14=$C_4;
                                $total14=$store14+$total14;
                                $avg14=$total14/$index+1;
                                echo $avg14;
                                $index++;

                            }
                            else if($C_6=='Team Leader')
                            {
                                $store21=$C_1;
                                $total21=$store21+$total21;
                                $avg21=$total21/$index+1;
                                echo $avg21;
                                $store22=$C_2;
                                $total22=$store22+$total22;
                                $avg22=$total22/$index+1;
                                echo $avg22;
                                $store23=$C_3;
                                $total23=$store23+$total23;
                                $avg23=$total23/$index+1;
                                echo $avg23;
                                $store24=$C_4;
                                $total24=$store24+$total24;
                                $avg24=$total24/$index+1;
                                echo $avg24;
                                $index++;

                            }
                            else
                            {
                              echo 'Error...';
                            }
                      ?>
                             [<?php if($C_6=='Intern')
                              {
                             echo $avg1;
                              }
                             elseif ($C_6=='Employee')
                              {
                               echo $avg11;
                             }
                             elseif ($C_6=='Team Leader')
                              {
                               echo $avg21;
                             }
                             else
                             {
                              echo "error";
                             }
                              ?>,
                              <?php if($C_6=='Intern')
                              {
                             echo $avg2;
                              }
                             elseif ($C_6=='Employee')
                              {
                               echo $avg12;
                             }
                             elseif ($C_6=='Team Leader')
                              {
                               echo $avg22;
                             }
                             else
                             {
                              echo "error";
                             }
                              ?>,
                              <?php if($C_6=='Intern')
                              {
                             echo $avg3;
                              }
                             elseif ($C_6=='Employee')
                              {
                               echo $avg13;
                             }
                             elseif ($C_6=='Team Leader')
                              {
                               echo $avg23;
                             }
                             else
                             {
                              echo "error";
                             }
                              ?>,
                              <?php if($C_6=='Intern')
                              {
                             echo $avg4;
                              }
                             elseif ($C_6=='Employee')
                              {
                               echo $avg14;
                             }
                             elseif ($C_6=='Team Leader')
                              {
                               echo $avg24;
                             }
                             else
                             {
                              echo "error";
                             }
                              ?>,<?php echo (($C_1+$C_2+$C_3+$C_4) / 4); ?>]
                      <?php
                            $index++;

                      ?>
           ]);

    var options = {
      title : 'Monthly rating of Manager',
      vAxis: {title: 'Manager'},
      hAxis: {title: 'Name'},
      seriesType: 'bars',
      series: {4: {type: 'line'}},
      colors:['Orange','Red','Blue','Grey'],

    };

    var chart = new google.visualization.ComboChart(document.getElementById('chart_div'));
    chart.draw(data, options);
  }
    </script>
  </head>
  <body>

    <div id="chart_div" style="width: 900px; height: 500px;"></div>
  </body>
</html>

我收到Parse语法错误 任何帮助将不胜感激

0 个答案:

没有答案