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
   |  
 
<?php
 
mysql_connect ('localhost','root','');
 
mysql_select_db ('projetxml2');
 
$val2=mysql_query("select  count(*)*100/t.total as 'Pourcentage règles complete',r.statut    from regle  r   , (select count(*) total from regle)
 as t  group by  r.statut");
 
 while($row2=mysql_fetch_array($val2))
{
 
 echo "<br>"; 
 echo "<Strong>";
echo "Pourcentage regle OK pour la machine  "   .$row2['statut']  .    " est :"." "." "." ".  $row2[0]."%";
echo "</Strong>";
echo "<br/>";
    $rows[] = $row2;
}
 
print json_encode($rows);
 
?>
 
<html>
  <head>
    <!--Load the AJAX API-->
    <script type="text/javascript" src="https://www.google.com/jsapi"></script>
    <script type="text/javascript" src="jquery-1.6.2.min.js"></script>
    <script type="text/javascript">
 
    // Load the Visualization API and the piechart package.
    google.load('visualization', '1', {'packages':['corechart']});
 
    // Set a callback to run when the Google Visualization API is loaded.
    google.setOnLoadCallback(drawChart);
 
    function drawChart() {
      var jsonData = $.ajax({
          url: "index.php",
          dataType:"json",
          async: false
          }).responseText;
 
      // Create our data table out of JSON data loaded from server.
      var data = new google.visualization.DataTable(jsonData);
 
      // Instantiate and draw our chart, passing in some options.
      var chart = new google.visualization.PieChart(document.getElementById('chart_div'));
      chart.draw(data, {width: 400, height: 240});
    }
 
    </script>
  </head>
 
  <body>
    <!--Div that will hold the pie chart-->
    <div id="chart_div"></div>
  </body>
</html> | 
Partager